1
0
forked from me/IronOS

Further work on Pinecil compile

This commit is contained in:
Ben V. Brown
2020-08-18 18:58:00 +10:00
parent 3560f6c5c1
commit 2becaa5eab
22 changed files with 1214 additions and 1260 deletions

View File

@@ -18,6 +18,6 @@ RUN wget -qO- https://github.com/riscv-mcu/riscv-gnu-toolchain/releases/download
# Add compiler to the path
ENV PATH "/build/gcc-arm-none-eabi-9-2020-q2-update/bin:$PATH"
ENV PATH "/build/rv_linux_bare_1908291308/bin:$PATH"
ENV PATH "/build/rv_linux_bare_1908312208/bin/:$PATH"
COPY . /build/source
COPY ./ci /build/ci

View File

@@ -12,7 +12,8 @@ SemaphoreHandle_t FRToSI2C::I2CSemaphore;
StaticSemaphore_t FRToSI2C::xSemaphoreBuffer;
#define FLAG_TIMEOUT 1000
void FRToSI2C::CpltCallback() {
void FRToSI2C::CpltCallback()
{
//TODO
}
@@ -20,28 +21,31 @@ void FRToSI2C::CpltCallback() {
*
* @param obj The I2C object
*/
int i2c_start() {
int i2c_start()
{
int timeout;
/* clear I2C_FLAG_AERR Flag */
i2c_flag_clear(I2C0, I2C_FLAG_AERR);
/* wait until I2C_FLAG_I2CBSY flag is reset */
timeout = FLAG_TIMEOUT
;
while ((i2c_flag_get(I2C0, I2C_FLAG_I2CBSY)) == SET) {
if ((timeout--) == 0) {
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_I2CBSY)) == SET)
{
if ((timeout--) == 0)
{
return (int) -1;
return (int)-1;
}
}
/* ensure the i2c has been stopped */
timeout = FLAG_TIMEOUT
;
while ((I2C_CTL0(I2C0) & I2C_CTL0_STOP) == I2C_CTL0_STOP) {
if ((timeout--) == 0) {
return (int) -1;
timeout = FLAG_TIMEOUT;
while ((I2C_CTL0(I2C0) & I2C_CTL0_STOP) == I2C_CTL0_STOP)
{
if ((timeout--) == 0)
{
return (int)-1;
}
}
@@ -49,30 +53,34 @@ int i2c_start() {
i2c_start_on_bus(I2C0);
/* ensure the i2c has been started successfully */
timeout = FLAG_TIMEOUT
;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET) {
if ((timeout--) == 0) {
return (int) -1;
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET)
{
if ((timeout--) == 0)
{
return (int)-1;
}
}
return (int) 0;
return (int)0;
}
/** Send STOP command
*
* @param obj The I2C object
*/
int i2c_stop() {
int i2c_stop()
{
/* generate a STOP condition */
i2c_stop_on_bus(I2C0);
/* wait for STOP bit reset */
int timeout = FLAG_TIMEOUT;
while ((I2C_CTL0(I2C0) & I2C_CTL0_STOP)) {
if ((timeout--) == 0) {
while ((I2C_CTL0(I2C0) & I2C_CTL0_STOP))
{
if ((timeout--) == 0)
{
return -1;
}
}
@@ -86,26 +94,32 @@ int i2c_stop() {
* @param last Acknoledge
* @return The read byte
*/
int i2c_byte_read(int last) {
int i2c_byte_read(int last)
{
int timeout;
if (last) {
if (last)
{
/* disable acknowledge */
i2c_ack_config(I2C0, I2C_ACK_DISABLE);
} else {
}
else
{
/* enable acknowledge */
i2c_ack_config(I2C0, I2C_ACK_ENABLE);
}
/* wait until the byte is received */
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_RBNE)) == RESET) {
if ((timeout--) == 0) {
while ((i2c_flag_get(I2C0, I2C_FLAG_RBNE)) == RESET)
{
if ((timeout--) == 0)
{
return -1;
}
}
return (int) i2c_data_receive(I2C0);
return (int)i2c_data_receive(I2C0);
}
/** Write one byte
@@ -114,15 +128,17 @@ int i2c_byte_read(int last) {
* @param data Byte to be written
* @return 0 if NAK was received, 1 if ACK was received, 2 for timeout.
*/
int i2c_byte_write(int data) {
int i2c_byte_write(int data)
{
int timeout;
i2c_data_transmit(I2C0, data);
/* wait until the byte is transmitted */
timeout = FLAG_TIMEOUT;
while (((i2c_flag_get(I2C0, I2C_FLAG_TBE)) == RESET)
|| ((i2c_flag_get(I2C0, I2C_FLAG_BTC)) == RESET)) {
if ((timeout--) == 0) {
while (((i2c_flag_get(I2C0, I2C_FLAG_TBE)) == RESET) || ((i2c_flag_get(I2C0, I2C_FLAG_BTC)) == RESET))
{
if ((timeout--) == 0)
{
return 2;
}
}
@@ -131,7 +147,8 @@ int i2c_byte_write(int data) {
}
bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
uint8_t *pData, uint16_t Size) {
uint8_t *pData, uint16_t Size)
{
if (!lock())
return false;
@@ -140,13 +157,18 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
/* wait until I2C_FLAG_I2CBSY flag is reset */
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_I2CBSY)) == SET) {
if ((timeout--) == 0) {
while ((i2c_flag_get(I2C0, I2C_FLAG_I2CBSY)) == SET)
{
if ((timeout--) == 0)
{
i2c_stop();
unlock();
return false;
} else {
if (timeout % 5 == 0) {
}
else
{
if (timeout % 5 == 0)
{
i2c_stop();
}
}
@@ -155,10 +177,11 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
i2c_start_on_bus(I2C0);
/* ensure the i2c has been started successfully */
timeout = FLAG_TIMEOUT
;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET) {
if ((timeout--) == 0) {
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET)
{
if ((timeout--) == 0)
{
i2c_stop();
unlock();
return false;
@@ -170,9 +193,11 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
timeout = 0;
/* wait until I2C_FLAG_ADDSEND flag is set */
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND))
{
timeout++;
if (timeout > 100000) {
if (timeout > 100000)
{
i2c_stop();
unlock();
return false;
@@ -180,7 +205,8 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
}
bool no_ack = i2c_flag_get(I2C0, I2C_FLAG_AERR);
no_ack |= i2c_flag_get(I2C0, I2C_FLAG_BERR);
if (no_ack) {
if (no_ack)
{
i2c_stop();
unlock();
return false;
@@ -190,21 +216,23 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
int status = i2c_byte_write(MemAddress);
no_ack |= i2c_flag_get(I2C0, I2C_FLAG_BERR);
no_ack |= i2c_flag_get(I2C0, I2C_FLAG_LOSTARB);
if (status == 2 || no_ack) {
if (status == 2 || no_ack)
{
i2c_stop();
unlock();
return false;
}
//////////////////////////// //Restart into read
//////////////////////////// //Restart into read
/* generate a START condition */
i2c_start_on_bus(I2C0);
/* ensure the i2c has been started successfully */
timeout = FLAG_TIMEOUT
;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET) {
if ((timeout--) == 0) {
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET)
{
if ((timeout--) == 0)
{
i2c_stop();
unlock();
return false;
@@ -216,9 +244,11 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
timeout = 0;
/* wait until I2C_FLAG_ADDSEND flag is set */
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND))
{
timeout++;
if (timeout > 100000) {
if (timeout > 100000)
{
i2c_stop();
unlock();
return false;
@@ -228,13 +258,15 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
/* clear ADDSEND */
i2c_flag_clear(I2C0, I2C_FLAG_ADDSEND);
no_ack = i2c_flag_get(I2C0, I2C_FLAG_AERR);
if (no_ack) {
if (no_ack)
{
i2c_stop();
unlock();
return false;
}
for (count = 0; count < Size; count++) {
pData[count] = i2c_byte_read(count == (Size - 1));
for (count = 0; count < Size; count++)
{
pData[count] = i2c_byte_read(count == (uint32_t)(Size - 1));
}
/* if not sequential write, then send stop */
@@ -243,17 +275,20 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
unlock();
return true;
}
void FRToSI2C::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data) {
void FRToSI2C::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data)
{
Mem_Write(address, reg, &data, 1);
}
uint8_t FRToSI2C::I2C_RegisterRead(uint8_t add, uint8_t reg) {
uint8_t FRToSI2C::I2C_RegisterRead(uint8_t add, uint8_t reg)
{
uint8_t temp = 0;
Mem_Read(add, reg, &temp, 1);
return temp;
}
void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
uint8_t *pData, uint16_t Size) {
uint8_t *pData, uint16_t Size)
{
if (!lock())
return;
@@ -261,15 +296,19 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
int timeout = 0;
/* wait until I2C_FLAG_I2CBSY flag is reset */
timeout = FLAG_TIMEOUT
;
while ((i2c_flag_get(I2C0, I2C_FLAG_I2CBSY)) == SET) {
if ((timeout--) == 0) {
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_I2CBSY)) == SET)
{
if ((timeout--) == 0)
{
i2c_stop();
unlock();
return;
} else {
if (timeout % 5 == 0) {
}
else
{
if (timeout % 5 == 0)
{
i2c_stop();
}
}
@@ -278,10 +317,11 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
i2c_start_on_bus(I2C0);
/* ensure the i2c has been started successfully */
timeout = FLAG_TIMEOUT
;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET) {
if ((timeout--) == 0) {
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET)
{
if ((timeout--) == 0)
{
i2c_stop();
unlock();
return;
@@ -293,9 +333,11 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
timeout = 0;
/* wait until I2C_FLAG_ADDSEND flag is set */
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND))
{
timeout++;
if (timeout > 100000) {
if (timeout > 100000)
{
i2c_stop();
unlock();
return;
@@ -305,9 +347,11 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
/* clear ADDSEND */
i2c_flag_clear(I2C0, I2C_FLAG_ADDSEND);
int status = i2c_byte_write(MemAddress);
for (count = 0; count < Size; count++) {
for (count = 0; count < Size; count++)
{
status = i2c_byte_write(pData[count]);
if (status != 1) {
if (status != 1)
{
i2c_stop();
unlock();
return;
@@ -320,7 +364,8 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
unlock();
}
void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size)
{
if (!lock())
return;
uint32_t count = 0;
@@ -328,13 +373,18 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
/* wait until I2C_FLAG_I2CBSY flag is reset */
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_I2CBSY)) == SET) {
if ((timeout--) == 0) {
while ((i2c_flag_get(I2C0, I2C_FLAG_I2CBSY)) == SET)
{
if ((timeout--) == 0)
{
i2c_stop();
unlock();
return;
} else {
if (timeout % 5 == 0) {
}
else
{
if (timeout % 5 == 0)
{
i2c_stop();
}
}
@@ -343,10 +393,11 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
i2c_start_on_bus(I2C0);
/* ensure the i2c has been started successfully */
timeout = FLAG_TIMEOUT
;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET) {
if ((timeout--) == 0) {
timeout = FLAG_TIMEOUT;
while ((i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) == RESET)
{
if ((timeout--) == 0)
{
i2c_stop();
unlock();
return;
@@ -358,9 +409,11 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
timeout = 0;
/* wait until I2C_FLAG_ADDSEND flag is set */
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND))
{
timeout++;
if (timeout > 100000) {
if (timeout > 100000)
{
i2c_stop();
unlock();
return;
@@ -370,9 +423,11 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
/* clear ADDSEND */
i2c_flag_clear(I2C0, I2C_FLAG_ADDSEND);
for (count = 0; count < Size; count++) {
for (count = 0; count < Size; count++)
{
int status = i2c_byte_write(pData[count]);
if (status != 1) {
if (status != 1)
{
i2c_stop();
unlock();
return;
@@ -385,7 +440,8 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
unlock();
}
bool FRToSI2C::probe(uint16_t DevAddress) {
bool FRToSI2C::probe(uint16_t DevAddress)
{
if (!lock())
return false;
i2c_start();
@@ -393,14 +449,16 @@ bool FRToSI2C::probe(uint16_t DevAddress) {
i2c_master_addressing(I2C0, DevAddress, I2C_TRANSMITTER);
/* wait until ADDSEND bit is set */
int timeout = FLAG_TIMEOUT;
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {
if (i2c_flag_get(I2C0, I2C_FLAG_AERR)
|| i2c_flag_get(I2C0, I2C_FLAG_BERR)) {
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND))
{
if (i2c_flag_get(I2C0, I2C_FLAG_AERR) || i2c_flag_get(I2C0, I2C_FLAG_BERR))
{
i2c_stop();
unlock();
return false;
}
if (timeout-- == 0) {
if (timeout-- == 0)
{
i2c_stop();
unlock();
return false;
@@ -422,17 +480,20 @@ bool FRToSI2C::probe(uint16_t DevAddress) {
return !no_ack;
}
void FRToSI2C::I2C_Unstick() {
void FRToSI2C::I2C_Unstick()
{
unstick_I2C();
}
bool FRToSI2C::lock() {
bool FRToSI2C::lock()
{
if (I2CSemaphore == nullptr)
return true;
return xSemaphoreTake(I2CSemaphore,1000) == pdTRUE;
return xSemaphoreTake(I2CSemaphore, 1000) == pdTRUE;
}
void FRToSI2C::unlock() {
void FRToSI2C::unlock()
{
if (I2CSemaphore == nullptr)
return;
xSemaphoreGive(I2CSemaphore);

View File

@@ -0,0 +1,27 @@
/*
* Model_Config.h
*
* Created on: 25 Jul 2020
* Author: Ralim
*/
#ifndef BSP_MINIWARE_MODEL_CONFIG_H_
#define BSP_MINIWARE_MODEL_CONFIG_H_
/*
* Lookup for mapping features <-> Models
*/
#if defined(MODEL_Pinecil) > 1
#error "Multiple models defined!"
#elif defined(MODEL_Pinecil) == 0
#error "No model defined!"
#endif
#ifdef MODEL_Pinecil
#define ACCEL_LIS
#define TEMP_TMP36
#define POW_QC
#define POW_PD
#endif
#endif /* BSP_MINIWARE_MODEL_CONFIG_H_ */

View File

@@ -1,3 +1,4 @@
#include "FreeRTOSConfig.h"
#include "FreeRTOS.h"
#include "task.h"
#include "portmacro.h"
@@ -6,36 +7,32 @@
#include "riscv_encoding.h"
#include "n200_timer.h"
#include "n200_eclic.h"
/* Standard Includes */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
/* Each task maintains its own interrupt status in the critical nesting variable. */
UBaseType_t uxCriticalNesting = 0xaaaaaaaa;
#if USER_MODE_TASKS
#ifdef __riscv_flen
unsigned long MSTATUS_INIT = (MSTATUS_MPIE | (0x1 << 13));
unsigned long MSTATUS_INIT = (MSTATUS_MPIE | (0x1 << 13));
#else
unsigned long MSTATUS_INIT = (MSTATUS_MPIE);
unsigned long MSTATUS_INIT = (MSTATUS_MPIE);
#endif
#else
#ifdef __riscv_flen
unsigned long MSTATUS_INIT = (MSTATUS_MPP | MSTATUS_MPIE | (0x1 << 13));
unsigned long MSTATUS_INIT = (MSTATUS_MPP | MSTATUS_MPIE | (0x1 << 13));
#else
unsigned long MSTATUS_INIT = (MSTATUS_MPP | MSTATUS_MPIE);
unsigned long MSTATUS_INIT = (MSTATUS_MPP | MSTATUS_MPIE);
#endif
#endif
/*
* Used to catch tasks that attempt to return from their implementing function.
*/
static void prvTaskExitError( void );
static void prvTaskExitError(void);
/**
* @brief System Call Trap
@@ -47,52 +44,51 @@ static void prvTaskExitError( void );
*/
unsigned long ulSynchTrap(unsigned long mcause, unsigned long sp, unsigned long arg1)
{
switch(mcause&0X00000fff)
switch (mcause & 0X00000fff)
{
//on User and Machine ECALL, handler the request
case 8:
case 11:
//on User and Machine ECALL, handler the request
case 8:
case 11:
{
if (arg1 == IRQ_DISABLE)
{
if(arg1==IRQ_DISABLE)
{
//zero out mstatus.mpie
clear_csr(mstatus,MSTATUS_MPIE);
}
else if(arg1==IRQ_ENABLE)
{
//set mstatus.mpie
set_csr(mstatus,MSTATUS_MPIE);
}
else if(arg1==PORT_YIELD)
{
//always yield from machine mode
//fix up mepc on sync trap
unsigned long epc = read_csr(mepc);
vPortYield_from_ulSynchTrap(sp,epc+4);
}
else if(arg1==PORT_YIELD_TO_RA)
{
vPortYield_from_ulSynchTrap(sp,(*(unsigned long*)(sp+1*sizeof(sp))));
}
break;
//zero out mstatus.mpie
clear_csr(mstatus, MSTATUS_MPIE);
}
default:
else if (arg1 == IRQ_ENABLE)
{
/* 异常处理 */
extern uintptr_t handle_trap(uintptr_t mcause, uintptr_t sp);
handle_trap(mcause,sp);
//set mstatus.mpie
set_csr(mstatus, MSTATUS_MPIE);
}
else if (arg1 == PORT_YIELD)
{
//always yield from machine mode
//fix up mepc on sync trap
unsigned long epc = read_csr(mepc);
vPortYield_from_ulSynchTrap(sp, epc + 4);
}
else if (arg1 == PORT_YIELD_TO_RA)
{
vPortYield_from_ulSynchTrap(sp, (*(unsigned long *)(sp + 1 * sizeof(sp))));
}
break;
}
default:
{
/* 异常处理 */
extern uintptr_t handle_trap(uintptr_t mcause, uintptr_t sp);
handle_trap(mcause, sp);
}
}
//fix mepc and return
unsigned long epc = read_csr(mepc);
write_csr(mepc,epc+4);
write_csr(mepc, epc + 4);
return sp;
}
/*-----------------------------------------------------------*/
/**
* @brief 设置触发软中断
* @note 目的是在软中断内进行任务上下文切换
@@ -100,24 +96,22 @@ unsigned long ulSynchTrap(unsigned long mcause, unsigned long sp, unsigned long
*/
void vPortSetMSIPInt(void)
{
*(volatile uint8_t *) (TIMER_CTRL_ADDR + TIMER_MSIP) |=0x01;
*(volatile uint8_t *)(TIMER_CTRL_ADDR + TIMER_MSIP) |= 0x01;
__asm volatile("fence");
__asm volatile("fence.i");
}
/*-----------------------------------------------------------*/
/**
* @brief 清除软中断
*
*/
void vPortClearMSIPInt(void)
{
*(volatile uint8_t *) (TIMER_CTRL_ADDR + TIMER_MSIP) &= ~0x01;
*(volatile uint8_t *)(TIMER_CTRL_ADDR + TIMER_MSIP) &= ~0x01;
}
/*-----------------------------------------------------------*/
/**
* @brief 执行任务上下文切换,在portasm.S中被调用
*
@@ -125,23 +119,22 @@ void vPortClearMSIPInt(void)
* @param arg1
* @return unsigned long sp地址
*/
unsigned long taskswitch( unsigned long sp, unsigned long arg1)
unsigned long taskswitch(unsigned long sp, unsigned long arg1)
{
//always yield from machine mode
//fix up mepc on
unsigned long epc = read_csr(mepc);
vPortYield(sp,epc); //never returns
vPortYield(sp, epc); //never returns
return sp;
}
/*-----------------------------------------------------------*/
/**
* @brief 调研freertos内建函数vTaskSwitchContext,在portasm.S中被调用
*
*/
void vDoTaskSwitchContext( void )
void vDoTaskSwitchContext(void)
{
portDISABLE_INTERRUPTS();
vTaskSwitchContext();
@@ -149,45 +142,42 @@ void vDoTaskSwitchContext( void )
}
/*-----------------------------------------------------------*/
/**
* @brief 进入临界段
*
*/
void vPortEnterCritical( void )
void vPortEnterCritical(void)
{
#if USER_MODE_TASKS
ECALL(IRQ_DISABLE);
#else
portDISABLE_INTERRUPTS();
#endif
#if USER_MODE_TASKS
ECALL(IRQ_DISABLE);
#else
portDISABLE_INTERRUPTS();
#endif
uxCriticalNesting++;
}
/*-----------------------------------------------------------*/
/**
* @brief 退出临界段
*
*/
void vPortExitCritical( void )
void vPortExitCritical(void)
{
configASSERT( uxCriticalNesting );
configASSERT(uxCriticalNesting);
uxCriticalNesting--;
if( uxCriticalNesting == 0 )
if (uxCriticalNesting == 0)
{
#if USER_MODE_TASKS
ECALL(IRQ_ENABLE);
#else
portENABLE_INTERRUPTS();
#endif
#if USER_MODE_TASKS
ECALL(IRQ_ENABLE);
#else
portENABLE_INTERRUPTS();
#endif
}
return;
}
/*-----------------------------------------------------------*/
/**
* @brief Clear current interrupt mask and set given mask
*
@@ -195,11 +185,10 @@ void vPortExitCritical( void )
*/
void vPortClearInterruptMask(int int_mask)
{
eclic_set_mth (int_mask);
eclic_set_mth(int_mask);
}
/*-----------------------------------------------------------*/
/**
* @brief Set interrupt mask and return current interrupt enable register
*
@@ -207,15 +196,14 @@ void vPortClearInterruptMask(int int_mask)
*/
int xPortSetInterruptMask(void)
{
int int_mask=0;
int_mask=eclic_get_mth();
int int_mask = 0;
int_mask = eclic_get_mth();
portDISABLE_INTERRUPTS();
return int_mask;
}
/*-----------------------------------------------------------*/
/**
* @brief 初始化任务栈帧
*
@@ -224,30 +212,30 @@ int xPortSetInterruptMask(void)
* @param pvParameters 任务参数
* @return StackType_t* 完成初始化后的栈顶
*/
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters)
{
/* Simulate the stack frame as it would be created by a context switch
interrupt. */
#ifdef __riscv_flen
pxTopOfStack -= 32; /* 浮点寄存器 */
pxTopOfStack -= 32; /* 浮点寄存器 */
#endif
pxTopOfStack--;
*pxTopOfStack = 0xb8000000; /* CSR_MCAUSE */
*pxTopOfStack = 0xb8000000; /* CSR_MCAUSE */
pxTopOfStack--;
*pxTopOfStack = 0x40; /* CSR_SUBM */
*pxTopOfStack = 0x40; /* CSR_SUBM */
pxTopOfStack--;
*pxTopOfStack = (portSTACK_TYPE)pxCode; /* Start address */
*pxTopOfStack = (portSTACK_TYPE)pxCode; /* Start address */
pxTopOfStack--;
*pxTopOfStack = MSTATUS_INIT; /* CSR_MSTATUS */
*pxTopOfStack = MSTATUS_INIT; /* CSR_MSTATUS */
pxTopOfStack -= 22;
*pxTopOfStack = (portSTACK_TYPE)pvParameters; /* Register a0 */
*pxTopOfStack = (portSTACK_TYPE)pvParameters; /* Register a0 */
pxTopOfStack -=9;
pxTopOfStack -= 9;
*pxTopOfStack = (portSTACK_TYPE)prvTaskExitError; /* Register ra */
pxTopOfStack--;
@@ -255,25 +243,24 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
}
/*-----------------------------------------------------------*/
/**
* @brief 任务退出函数
*
*/
void prvTaskExitError( void )
void prvTaskExitError(void)
{
/* A function that implements a task must not exit or attempt to return to
its caller as there is nothing to return to. If a task wants to exit it
should instead call vTaskDelete( NULL ).
Artificially force an assert() to be triggered if configASSERT() is
defined, then stop here so application writers can catch the error. */
configASSERT( uxCriticalNesting == ~0UL );
configASSERT(uxCriticalNesting == ~0UL);
portDISABLE_INTERRUPTS();
for( ;; );
for (;;)
;
}
/*-----------------------------------------------------------*/
/**
* @brief tick中断
* @note 由于该中断配置为向量模式则中断到来会调用portasm.S的MTIME_HANDLER,进行栈帧保存之后该函数会调用vPortSysTickHandler
@@ -281,39 +268,38 @@ void prvTaskExitError( void )
*/
void vPortSysTickHandler(void)
{
volatile uint64_t * mtime = (uint64_t*) (TIMER_CTRL_ADDR + TIMER_MTIME);
volatile uint64_t * mtimecmp = (uint64_t*) (TIMER_CTRL_ADDR + TIMER_MTIMECMP);
volatile uint64_t *mtime = (uint64_t *)(TIMER_CTRL_ADDR + TIMER_MTIME);
volatile uint64_t *mtimecmp = (uint64_t *)(TIMER_CTRL_ADDR + TIMER_MTIMECMP);
UBaseType_t uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
#if CONFIG_SYSTEMVIEW_EN
#if CONFIG_SYSTEMVIEW_EN
traceISR_ENTER();
#endif
#endif
uint64_t now = *mtime;
now += (configRTC_CLOCK_HZ / configTICK_RATE_HZ);
*mtimecmp = now;
/* 调用freertos的tick增加接口 */
if( xTaskIncrementTick() != pdFALSE )
if (xTaskIncrementTick() != pdFALSE)
{
#if CONFIG_SYSTEMVIEW_EN
#if CONFIG_SYSTEMVIEW_EN
traceISR_EXIT_TO_SCHEDULER();
#endif
#endif
portYIELD();
}
#if CONFIG_SYSTEMVIEW_EN
#if CONFIG_SYSTEMVIEW_EN
else
{
traceISR_EXIT();
}
#endif
#endif
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedInterruptStatus);
}
/*-----------------------------------------------------------*/
/**
* @brief 初始化tick
*
@@ -321,21 +307,20 @@ void vPortSysTickHandler(void)
void vPortSetupTimer(void)
{
/* 内核timer定时器使用64位的计数器来实现 */
volatile uint64_t * mtime = (uint64_t*) (TIMER_CTRL_ADDR + TIMER_MTIME);
volatile uint64_t * mtimecmp = (uint64_t*) (TIMER_CTRL_ADDR + TIMER_MTIMECMP);
volatile uint64_t *mtime = (uint64_t *)(TIMER_CTRL_ADDR + TIMER_MTIME);
volatile uint64_t *mtimecmp = (uint64_t *)(TIMER_CTRL_ADDR + TIMER_MTIMECMP);
portENTER_CRITICAL();
uint64_t now = *mtime;
now += (configRTC_CLOCK_HZ / configTICK_RATE_HZ);
*mtimecmp = now;
uint64_t now = *mtime;
now += (configRTC_CLOCK_HZ / configTICK_RATE_HZ);
*mtimecmp = now;
portEXIT_CRITICAL();
eclic_set_vmode(CLIC_INT_TMR);
eclic_irq_enable(CLIC_INT_TMR,configKERNEL_INTERRUPT_PRIORITY>>configPRIO_BITS,0);
eclic_irq_enable(CLIC_INT_TMR, configKERNEL_INTERRUPT_PRIORITY >> configPRIO_BITS, 0);
}
/*-----------------------------------------------------------*/
/**
* @brief 初始化软中断
*
@@ -343,11 +328,10 @@ void vPortSetupTimer(void)
void vPortSetupMSIP(void)
{
eclic_set_vmode(CLIC_INT_SFT);
eclic_irq_enable(CLIC_INT_SFT,configKERNEL_INTERRUPT_PRIORITY>>configPRIO_BITS,0);
eclic_irq_enable(CLIC_INT_SFT, configKERNEL_INTERRUPT_PRIORITY >> configPRIO_BITS, 0);
}
/*-----------------------------------------------------------*/
/**
* @brief 调度启动前的初始化准备
*

View File

@@ -1,14 +1,13 @@
#ifndef PORTMACRO_H
#define PORTMACRO_H
#ifndef PINE_PORTMACRO_H
#define PINE_PORTMACRO_H
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include "riscv_encoding.h"
/*-----------------------------------------------------------
* Port specific definitions.
*
@@ -20,123 +19,128 @@ extern "C" {
*/
/* Type definitions. */
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE uint32_t
#define portBASE_TYPE long
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE uint32_t
#define portBASE_TYPE long
typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
#if( configUSE_16_BIT_TICKS == 1 )
#if (configUSE_16_BIT_TICKS == 1)
typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff
#define portMAX_DELAY (TickType_t)0xffff
#else
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
typedef uint32_t TickType_t;
#define portMAX_DELAY (TickType_t)0xffffffffUL
#endif
/*-----------------------------------------------------------*/
/* Architecture specifics. */
#define portSTACK_GROWTH ( -1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
/*-----------------------------------------------------------*/
/* Architecture specifics. */
extern void vPortYield(unsigned long,unsigned long);
extern void vPortYield_from_ulSynchTrap(unsigned long,unsigned long);
extern int xPortSetInterruptMask(void);
extern void vPortClearInterruptMask( int uxSavedStatusValue );
#define portSTACK_GROWTH (-1)
#define portTICK_PERIOD_MS ((TickType_t)1000 / configTICK_RATE_HZ)
#define portBYTE_ALIGNMENT 8
/*-----------------------------------------------------------*/
/* Architecture specifics. */
extern void vPortYield(unsigned long, unsigned long);
extern void vPortYield_from_ulSynchTrap(unsigned long, unsigned long);
extern int xPortSetInterruptMask(void);
extern void vPortClearInterruptMask(int uxSavedStatusValue);
/*-----------------------------------------------------------*/
/*System Calls */
/*-----------------------------------------------------------*/
//ecall macro used to store argument in a3
#define ECALL(arg) ({ \
register uintptr_t a2 asm ("a2") = (uintptr_t)(arg); \
asm volatile ("ecall" \
: "+r" (a2) \
: \
: "memory"); \
a2; \
#define ECALL(arg) ({ \
register uintptr_t a2 asm("a2") = (uintptr_t)(arg); \
asm volatile("ecall" \
: "+r"(a2) \
: \
: "memory"); \
a2; \
})
extern void vPortSetMSIPInt(void);
extern void vPortSetMSIPInt(void);
#define port_MSIPSET_BIT vPortSetMSIPInt()
#define IRQ_DISABLE 20
#define IRQ_ENABLE 30
#define PORT_YIELD 40
#define PORT_YIELD_TO_RA 50
#define IRQ_DISABLE 20
#define IRQ_ENABLE 30
#define PORT_YIELD 40
#define PORT_YIELD_TO_RA 50
/*-----------------------------------------------------------*/
/* Scheduler utilities. */
/* the return after the ECALL is VERY important */
//#define portYIELD() ECALL(PORT_YIELD);
#define portYIELD() port_MSIPSET_BIT;
#if CONFIG_SYSTEMVIEW_EN
#define portEND_SWITCHING_ISR(xSwitchRequired) { if( xSwitchRequired != pdFALSE) { traceISR_EXIT_TO_SCHEDULER(); portYIELD(); } else {traceISR_EXIT(); } }
#ifdef CONFIG_SYSTEMVIEW_EN
#define portEND_SWITCHING_ISR(xSwitchRequired) \
{ \
if (xSwitchRequired != pdFALSE) \
{ \
traceISR_EXIT_TO_SCHEDULER(); \
portYIELD(); \
} \
else \
{ \
traceISR_EXIT(); \
} \
}
#else
#define portEND_SWITCHING_ISR(xSwitchRequired) if( xSwitchRequired != pdFALSE) portYIELD()
#define portEND_SWITCHING_ISR(xSwitchRequired) \
if (xSwitchRequired != pdFALSE) \
portYIELD()
#endif
#define portYIELD_FROM_ISR(x) portEND_SWITCHING_ISR(x)
#define portYIELD_FROM_ISR(x) portEND_SWITCHING_ISR(x)
/* Critical section management. */
extern void vPortEnterCritical( void );
extern void vPortExitCritical( void );
extern void eclic_set_mth (uint8_t mth);
#define portDISABLE_INTERRUPTS() \
{ \
eclic_set_mth((configMAX_SYSCALL_INTERRUPT_PRIORITY)|0x1f); \
__asm volatile("fence"); \
__asm volatile("fence.i"); \
}
#define portENABLE_INTERRUPTS() eclic_set_mth(0)
#define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) vPortClearInterruptMask( uxSavedStatusValue )
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
/* Critical section management. */
extern void vPortEnterCritical(void);
extern void vPortExitCritical(void);
extern void eclic_set_mth(uint8_t mth);
#define portDISABLE_INTERRUPTS() \
{ \
eclic_set_mth((configMAX_SYSCALL_INTERRUPT_PRIORITY) | 0x1f); \
__asm volatile("fence"); \
__asm volatile("fence.i"); \
}
#define portENABLE_INTERRUPTS() eclic_set_mth(0)
#define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedStatusValue) vPortClearInterruptMask(uxSavedStatusValue)
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
/*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. These are
not necessary for to use this port. They are defined so the common demo files
(which build with all the ports) will build. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)
#define portTASK_FUNCTION(vFunction, pvParameters) void vFunction(void *pvParameters)
/*-----------------------------------------------------------*/
/* Tickless idle/low power functionality. */
#ifndef portSUPPRESS_TICKS_AND_SLEEP
extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );
#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
extern void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime);
#define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) vPortSuppressTicksAndSleep(xExpectedIdleTime)
#endif
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
#define portINLINE __inline
#define portINLINE __inline
#ifndef portFORCE_INLINE
#define portFORCE_INLINE inline __attribute__(( always_inline))
#define portFORCE_INLINE inline __attribute__((always_inline))
#endif
#ifdef __cplusplus
}
#endif
#endif /* PORTMACRO_H */

View File

@@ -18,14 +18,16 @@
*
*
*/
class FRToSI2C {
class FRToSI2C
{
public:
static void init() {
static void init()
{
I2CSemaphore = nullptr;
}
static void FRToSInit() {
static void FRToSInit()
{
I2CSemaphore = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer);
xSemaphoreGive(I2CSemaphore);
}
@@ -33,20 +35,22 @@ public:
static void CpltCallback(); //Normal Tx Callback
static bool Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
uint8_t *pData, uint16_t Size);
uint8_t *pData, uint16_t Size);
static void Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
uint8_t *pData, uint16_t Size);
uint8_t *pData, uint16_t Size);
//Returns true if device ACK's being addressed
static bool probe(uint16_t DevAddress);
static void Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
static void Receive(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
static void TransmitReceive(uint16_t DevAddress, uint8_t *pData_tx,
uint16_t Size_tx, uint8_t *pData_rx, uint16_t Size_rx);
uint16_t Size_tx, uint8_t *pData_rx, uint16_t Size_rx);
static void I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data);
static uint8_t I2C_RegisterRead(uint8_t address, uint8_t reg);
private:
static bool lock();
static void unlock();
static void I2C_Unstick();
static SemaphoreHandle_t I2CSemaphore;
static StaticSemaphore_t xSemaphoreBuffer;

View File

@@ -10,43 +10,55 @@
#include "LIS2DH12.hpp"
#include "cmsis_os.h"
typedef struct {
typedef struct
{
const uint8_t reg;
const uint8_t value;
} LIS_REG;
static const LIS_REG i2c_registers[] = { { LIS_CTRL_REG1, 0x17 }, // 25Hz
{ LIS_CTRL_REG2, 0b00001000 }, // Highpass filter off
{ LIS_CTRL_REG3, 0b01100000 }, // Setup interrupt pins
{ LIS_CTRL_REG4, 0b00001000 }, // Block update mode off, HR on
{ LIS_CTRL_REG5, 0b00000010 }, { LIS_CTRL_REG6, 0b01100010 },
//Basically setup the unit to run, and enable 4D orientation detection
{ LIS_INT2_CFG, 0b01111110 }, //setup for movement detection
{ LIS_INT2_THS, 0x28 }, { LIS_INT2_DURATION, 64 }, {
LIS_INT1_CFG, 0b01111110 }, { LIS_INT1_THS, 0x28 }, {
LIS_INT1_DURATION, 64 } };
static const LIS_REG i2c_registers[] = {{LIS_CTRL_REG1, 0x17}, // 25Hz
{LIS_CTRL_REG2, 0b00001000}, // Highpass filter off
{LIS_CTRL_REG3, 0b01100000}, // Setup interrupt pins
{LIS_CTRL_REG4, 0b00001000}, // Block update mode off, HR on
{LIS_CTRL_REG5, 0b00000010},
{LIS_CTRL_REG6, 0b01100010},
//Basically setup the unit to run, and enable 4D orientation detection
{LIS_INT2_CFG, 0b01111110}, //setup for movement detection
{LIS_INT2_THS, 0x28},
{LIS_INT2_DURATION, 64},
{LIS_INT1_CFG, 0b01111110},
{LIS_INT1_THS, 0x28},
{LIS_INT1_DURATION, 64}};
void LIS2DH12::initalize() {
void LIS2DH12::initalize()
{
#ifdef ACCEL_LIS
for (size_t index = 0;
index < (sizeof(i2c_registers) / sizeof(i2c_registers[0]));
index++) {
index < (sizeof(i2c_registers) / sizeof(i2c_registers[0]));
index++)
{
FRToSI2C::I2C_RegisterWrite(LIS2DH_I2C_ADDRESS,
i2c_registers[index].reg, i2c_registers[index].value);
i2c_registers[index].reg, i2c_registers[index].value);
}
#endif
}
void LIS2DH12::getAxisReadings(int16_t &x, int16_t &y, int16_t &z) {
void LIS2DH12::getAxisReadings(int16_t &x, int16_t &y, int16_t &z)
{
#ifdef ACCEL_LIS
std::array<int16_t, 3> sensorData;
FRToSI2C::Mem_Read(LIS2DH_I2C_ADDRESS, 0xA8,
reinterpret_cast<uint8_t*>(sensorData.begin()),
sensorData.size() * sizeof(int16_t));
reinterpret_cast<uint8_t *>(sensorData.begin()),
sensorData.size() * sizeof(int16_t));
x = sensorData[0];
y = sensorData[1];
z = sensorData[2];
#endif
}
bool LIS2DH12::detect() {
bool LIS2DH12::detect()
{
return FRToSI2C::probe(LIS2DH_I2C_ADDRESS);
}

View File

@@ -11,15 +11,18 @@
#include "LIS2DH12_defines.hpp"
#include "BSP.h"
class LIS2DH12 {
class LIS2DH12
{
public:
static bool detect();
static void initalize();
//1 = rh, 2,=lh, 8=flat
static Orientation getOrientation() {
static Orientation getOrientation()
{
#ifdef LIS_ORI_FLIP
uint8_t val = (FRToSI2C::I2C_RegisterRead(LIS2DH_I2C_ADDRESS,
LIS_INT2_SRC) >> 2);
LIS_INT2_SRC) >>
2);
if (val == 8)
val = 3;
else if (val == 1)
@@ -30,11 +33,13 @@ public:
val = 3;
return static_cast<Orientation>(val);
#endif
#ifdef MODEL_TS100
return static_cast<Orientation>((FRToSI2C::I2C_RegisterRead(LIS2DH_I2C_ADDRESS,LIS_INT2_SRC) >> 2) - 1);
#ifdef ACCEL_LIS
return static_cast<Orientation>((FRToSI2C::I2C_RegisterRead(LIS2DH_I2C_ADDRESS, LIS_INT2_SRC) >> 2) - 1);
#else
return Orientation::ORIENTATION_FLAT;
#endif
}
static void getAxisReadings(int16_t& x, int16_t& y, int16_t& z);
static void getAxisReadings(int16_t &x, int16_t &y, int16_t &z);
private:
};

View File

@@ -9,20 +9,19 @@
#define INC_FREERTOSHOOKS_H_
#include "FreeRTOS.h"
#include "cmsis_os.h"
#include "unit.h"
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
// RToS
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize);
void vApplicationIdleHook(void);
// RToS
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize);
void vApplicationIdleHook(void);
#ifdef __cplusplus
}
#endif
#endif /* INC_FREERTOSHOOKS_H_ */

View File

@@ -10,9 +10,8 @@
#ifndef SETTINGS_H_
#define SETTINGS_H_
#include <stdint.h>
#include "stm32f1xx_hal.h"
#include "unit.h"
#define SETTINGSVERSION ( 0x20 )
#define SETTINGSVERSION (0x20)
/*Change this if you change the struct below to prevent people getting \
out of sync*/
@@ -20,47 +19,48 @@
* This struct must be a multiple of 2 bytes as it is saved / restored from
* flash in uint16_t chunks
*/
typedef struct {
uint8_t version; // Used to track if a reset is needed on firmware upgrade
typedef struct
{
uint8_t version; // Used to track if a reset is needed on firmware upgrade
uint16_t SolderingTemp; // current set point for the iron
uint16_t SleepTemp; // temp to drop to in sleep
uint8_t SleepTime; // minutes timeout to sleep
uint8_t cutoutSetting; // The voltage we cut out at for under voltage OR Power level for TS80
uint8_t OrientationMode :2; // If true we want to invert the display for lefties
uint8_t sensitivity :4; // Sensitivity of accelerometer (5 bits)
uint8_t autoStartMode :2; // Should the unit automatically jump straight
// into soldering mode when power is applied
uint8_t ShutdownTime; // Time until unit shuts down if left alone
uint8_t boostModeEnabled :1; // Boost mode swaps BUT_A in soldering mode to
// temporary soldering temp over-ride
uint8_t coolingTempBlink :1; // Should the temperature blink on the cool
// down screen until its <50C
uint8_t detailedIDLE :1; // Detailed idle screen
uint8_t detailedSoldering :1; // Detailed soldering screens
uint16_t SolderingTemp; // current set point for the iron
uint16_t SleepTemp; // temp to drop to in sleep
uint8_t SleepTime; // minutes timeout to sleep
uint8_t cutoutSetting; // The voltage we cut out at for under voltage OR Power level for TS80
uint8_t OrientationMode : 2; // If true we want to invert the display for lefties
uint8_t sensitivity : 4; // Sensitivity of accelerometer (5 bits)
uint8_t autoStartMode : 2; // Should the unit automatically jump straight
// into soldering mode when power is applied
uint8_t ShutdownTime; // Time until unit shuts down if left alone
uint8_t boostModeEnabled : 1; // Boost mode swaps BUT_A in soldering mode to
// temporary soldering temp over-ride
uint8_t coolingTempBlink : 1; // Should the temperature blink on the cool
// down screen until its <50C
uint8_t detailedIDLE : 1; // Detailed idle screen
uint8_t detailedSoldering : 1; // Detailed soldering screens
#ifdef ENABLED_FAHRENHEIT_SUPPORT
uint8_t temperatureInF :1; // Should the temp be in F or C (true is F)
uint8_t temperatureInF : 1; // Should the temp be in F or C (true is F)
#endif
uint8_t descriptionScrollSpeed :1; // Description scroll speed
uint8_t KeepAwakePulse; // Keep Awake pulse power in 0.1 watts (10 = 1Watt)
uint8_t descriptionScrollSpeed : 1; // Description scroll speed
uint8_t KeepAwakePulse; // Keep Awake pulse power in 0.1 watts (10 = 1Watt)
uint16_t voltageDiv; // Voltage divisor factor
uint16_t BoostTemp; // Boost mode set point for the iron
uint16_t voltageDiv; // Voltage divisor factor
uint16_t BoostTemp; // Boost mode set point for the iron
uint16_t CalibrationOffset; // This stores the temperature offset for this tip
// in the iron.
uint8_t powerLimitEnable; // Allow toggling of power limit without changing value
uint8_t powerLimit; // Maximum power iron allowed to output
uint8_t powerLimit; // Maximum power iron allowed to output
uint16_t TipGain; // uV/C * 10, it can be used to convert tip thermocouple voltage to temperateture TipV/TipGain = TipTemp
uint8_t ReverseButtonTempChangeEnabled; // Change the plus and minus button assigment
uint16_t TempChangeLongStep; // Change the plus and minus button assigment
uint16_t TempChangeShortStep; // Change the plus and minus button assigment
uint16_t TempChangeLongStep; // Change the plus and minus button assigment
uint16_t TempChangeShortStep; // Change the plus and minus button assigment
uint32_t padding; // This is here for in case we are not an even divisor so
// that nothing gets cut off
//MUST BE LAST
uint32_t padding; // This is here for in case we are not an even divisor so
// that nothing gets cut off
//MUST BE LAST
} systemSettingsType;

View File

@@ -8,19 +8,20 @@ extern uint32_t currentTempTargetDegC;
extern bool settingsWereReset;
extern bool usb_pd_available;
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
void vApplicationStackOverflowHook(xTaskHandle *pxTask,
signed portCHAR *pcTaskName);
void vApplicationStackOverflowHook(TaskHandle_t *pxTask,
signed portCHAR *pcTaskName);
//Threads
void startGUITask(void const *argument);
void startPIDTask(void const *argument);
void startMOVTask(void const *argument);
extern TaskHandle_t pidTaskNotification;
extern uint8_t accelInit;
extern uint32_t lastMovementTime;
//Threads
void startGUITask(void const *argument);
void startPIDTask(void const *argument);
void startMOVTask(void const *argument);
extern TaskHandle_t pidTaskNotification;
extern uint8_t accelInit;
extern uint32_t lastMovementTime;
#ifdef __cplusplus
}
#endif

View File

@@ -7,7 +7,9 @@
#include "FreeRTOSHooks.h"
#include "BSP.h"
void vApplicationIdleHook(void) {
#include "cmsis_os.h"
void vApplicationIdleHook(void)
{
resetWatchdog();
}
@@ -16,19 +18,19 @@ static StaticTask_t xIdleTaskTCBBuffer;
static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) {
StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize)
{
*ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
*ppxIdleTaskStackBuffer = &xIdleStack[0];
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
/* place for user code */
}
void vApplicationStackOverflowHook(xTaskHandle *pxTask,
signed portCHAR *pcTaskName) {
(void) pxTask;
(void) pcTaskName;
asm("bkpt");
// We dont have a good way to handle a stack overflow at this point in time
void vApplicationStackOverflowHook(TaskHandle_t *pxTask,
signed portCHAR *pcTaskName)
{
(void)pxTask;
(void)pcTaskName;
// We dont have a good way to handle a stack overflow at this point in time
reboot();
}

View File

@@ -20,7 +20,8 @@ TaskHandle_t pidTaskNotification = NULL;
uint32_t currentTempTargetDegC = 0; // Current temperature target in C
/* StartPIDTask function */
void startPIDTask(void const *argument __unused) {
void startPIDTask(void const *argument __unused)
{
/*
* We take the current tip temperature & evaluate the next step for the tip
* control PWM.
@@ -29,27 +30,32 @@ void startPIDTask(void const *argument __unused) {
TickType_t lastPowerPulseStart = 0;
TickType_t lastPowerPulseEnd = 0;
history<int32_t, PID_TIM_HZ> tempError = { { 0 }, 0, 0 };
history<int32_t, PID_TIM_HZ> tempError = {{0}, 0, 0};
currentTempTargetDegC = 0; // Force start with no output (off). If in sleep / soldering this will
// be over-ridden rapidly
pidTaskNotification = xTaskGetCurrentTaskHandle();
uint32_t PIDTempTarget = 0;
for (;;) {
for (;;)
{
if (ulTaskNotifyTake(pdTRUE, 2000)) {
if (ulTaskNotifyTake(pdTRUE, 2000))
{
// This is a call to block this thread until the ADC does its samples
int32_t x10WattsOut = 0;
// Do the reading here to keep the temp calculations churning along
uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
PIDTempTarget = currentTempTargetDegC;
if (PIDTempTarget) {
if (PIDTempTarget)
{
// Cap the max set point to 450C
if (PIDTempTarget > (450)) {
if (PIDTempTarget > (450))
{
//Maximum allowed output
PIDTempTarget = (450);
}
//Safety check that not aiming higher than current tip can measure
if (PIDTempTarget > TipThermoModel::getTipMaxInC()) {
if (PIDTempTarget > TipThermoModel::getTipMaxInC())
{
PIDTempTarget = TipThermoModel::getTipMaxInC();
}
// Convert the current tip to degree's C
@@ -73,7 +79,7 @@ void startPIDTask(void const *argument __unused) {
// Once we have feed-forward temp estimation we should be able to better tune this.
int32_t x10WattsNeeded = tempToX10Watts(tError);
// tempError.average());
// tempError.average());
// note that milliWattsNeeded is sometimes negative, this counters overshoot
// from I term's inertia.
x10WattsOut += x10WattsNeeded;
@@ -89,38 +95,41 @@ void startPIDTask(void const *argument __unused) {
// and counters extra power if the iron is no longer losing temp.
// basically: temp - lastTemp
// Unfortunately, our temp signal is too noisy to really help.
}
//If the user turns on the option of using an occasional pulse to keep the power bank on
if (systemSettings.KeepAwakePulse) {
if (systemSettings.KeepAwakePulse)
{
if (xTaskGetTickCount() - lastPowerPulseStart
> powerPulseRate) {
if (xTaskGetTickCount() - lastPowerPulseStart > powerPulseRate)
{
lastPowerPulseStart = xTaskGetTickCount();
lastPowerPulseEnd = lastPowerPulseStart
+ powerPulseDuration;
lastPowerPulseEnd = lastPowerPulseStart + powerPulseDuration;
}
//If current PID is less than the pulse level, check if we want to constrain to the pulse as the floor
if (x10WattsOut < systemSettings.KeepAwakePulse
&& xTaskGetTickCount() < lastPowerPulseEnd) {
if (x10WattsOut < systemSettings.KeepAwakePulse && xTaskGetTickCount() < lastPowerPulseEnd)
{
x10WattsOut = systemSettings.KeepAwakePulse;
}
}
//Secondary safety check to forcefully disable header when within ADC noise of top of ADC
if (getTipRawTemp(0) > (0x7FFF - 150)) {
if (getTipRawTemp(0) > (0x7FFF - 150))
{
x10WattsOut = 0;
}
if (systemSettings.powerLimitEnable
&& x10WattsOut > (systemSettings.powerLimit * 10)) {
if (systemSettings.powerLimitEnable && x10WattsOut > (systemSettings.powerLimit * 10))
{
setTipX10Watts(systemSettings.powerLimit * 10);
} else {
}
else
{
setTipX10Watts(x10WattsOut);
}
HAL_IWDG_Refresh(&hiwdg);
} else {
resetWatchdog();
}
else
{
//ADC interrupt timeout
setTipPWM(0);
}

View File

@@ -27,6 +27,7 @@ MINIWARE_INC_DIR = ./Core/BSP/Miniware
PINE_INC_DIR = ./Core/BSP/Pine64
PINE_VENDOR_INC_DIR = ./Core/BSP/Pine64/Vendor/Lib
PINE_RISCV_INC_DIR = ./Core/BSP/Pine64/Vendor/RISCV
PINE_N200_INC_DIR = ./Core/BSP/Pine64/N200
SOURCE_THREADS_DIR = ./Core/Threads
SOURCE_CORE_DIR = ./Core/Src
SOURCE_DRIVERS_DIR = ./Core/Drivers
@@ -45,6 +46,9 @@ DEVICE_INCLUDES = -I$(MINIWARE_INC_DIR) \
DEVICE_BSP_DIR = ./Core/BSP/Miniware
S_SRCS := ./Startup/startup_stm32f103t8ux.S
LDSCRIPT=stm32f103.ld
DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \
-D ARM_MATH_CM3 \
-D STM32F10X_MD
DEV_LDFLAGS=
DEV_AFLAGS=
DEV_CFLAGS=
@@ -55,12 +59,14 @@ ifeq ($(model),Pinecil)
DEVICE_INCLUDES = -I$(PINE_INC_DIR) \
-I$(PINE_INC_DIR)/N200 \
-I$(PINE_VENDOR_INC_DIR) \
-I$(PINE_RISCV_INC_DIR)
-I$(PINE_RISCV_INC_DIR) \
-I$(PINE_N200_INC_DIR)\
-I$(INC_PD_DRIVERS_DIR)
DEVICE_BSP_DIR = ./Core/BSP/Pine64
S_SRCS := $(shell find $(PINE_INC_DIR) -type f -name '*.s')
S_SRCS := $(shell find $(PINE_INC_DIR) -type f -name '*.S')
ASM_INC = -I$(PINE_RISCV_INC_DIR)
LDSCRIPT=GD32VF103x8.ld
LDSCRIPT=GD32VF103xB.ld
DEV_LDFLAGS=-nostartfiles
DEV_AFLAGS = -msmall-data-limit=8 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections
DEV_CFLAGS= -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
@@ -97,9 +103,7 @@ OPTIM=-Os -flto -ffat-lto-objects -finline-small-functions -findirect-inlining -
# global defines ---------------------------------------------------------------
GLOBAL_DEFINES += -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model) -D GCC_ARMCM3 \
-D ARM_MATH_CM3 \
-D STM32F10X_MD \
GLOBAL_DEFINES += -D LANG_$(lang) -D LANG -D MODEL_$(model) $(DEV_GLOBAL_DEFS)
# Enable debug code generation
DEBUG=-g3
@@ -277,6 +281,7 @@ $(OUT_HEXFILE).elf : $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) Makefile $(LDSCR
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
@test -d $(@D) || mkdir -p $(@D)
@echo Compiling ${<}
@echo @$(CC) -c $(CFLAGS) $< -o $@
@$(CC) -c $(CFLAGS) $< -o $@
@$(OBJDUMP) -d -S $@ > $@.lst

View File

@@ -1,279 +0,0 @@
/*
* FreeRTOS Kernel V10.3.1
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/
#ifndef DEPRECATED_DEFINITIONS_H
#define DEPRECATED_DEFINITIONS_H
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a
pre-processor definition was used to ensure the pre-processor found the correct
portmacro.h file for the port being used. That scheme was deprecated in favour
of setting the compiler's include path such that it found the correct
portmacro.h file - removing the need for the constant and allowing the
portmacro.h file to be located anywhere in relation to the port being used. The
definitions below remain in the code for backward compatibility only. New
projects should not use them. */
#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT
#include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h"
typedef void ( __interrupt __far *pxISR )();
#endif
#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT
#include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h"
typedef void ( __interrupt __far *pxISR )();
#endif
#ifdef GCC_MEGA_AVR
#include "../portable/GCC/ATMega323/portmacro.h"
#endif
#ifdef IAR_MEGA_AVR
#include "../portable/IAR/ATMega323/portmacro.h"
#endif
#ifdef MPLAB_PIC24_PORT
#include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"
#endif
#ifdef MPLAB_DSPIC_PORT
#include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"
#endif
#ifdef MPLAB_PIC18F_PORT
#include "../../Source/portable/MPLAB/PIC18F/portmacro.h"
#endif
#ifdef MPLAB_PIC32MX_PORT
#include "../../Source/portable/MPLAB/PIC32MX/portmacro.h"
#endif
#ifdef _FEDPICC
#include "libFreeRTOS/Include/portmacro.h"
#endif
#ifdef SDCC_CYGNAL
#include "../../Source/portable/SDCC/Cygnal/portmacro.h"
#endif
#ifdef GCC_ARM7
#include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h"
#endif
#ifdef GCC_ARM7_ECLIPSE
#include "portmacro.h"
#endif
#ifdef ROWLEY_LPC23xx
#include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h"
#endif
#ifdef IAR_MSP430
#include "..\..\Source\portable\IAR\MSP430\portmacro.h"
#endif
#ifdef GCC_MSP430
#include "../../Source/portable/GCC/MSP430F449/portmacro.h"
#endif
#ifdef ROWLEY_MSP430
#include "../../Source/portable/Rowley/MSP430F449/portmacro.h"
#endif
#ifdef ARM7_LPC21xx_KEIL_RVDS
#include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h"
#endif
#ifdef SAM7_GCC
#include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h"
#endif
#ifdef SAM7_IAR
#include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h"
#endif
#ifdef SAM9XE_IAR
#include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h"
#endif
#ifdef LPC2000_IAR
#include "..\..\Source\portable\IAR\LPC2000\portmacro.h"
#endif
#ifdef STR71X_IAR
#include "..\..\Source\portable\IAR\STR71x\portmacro.h"
#endif
#ifdef STR75X_IAR
#include "..\..\Source\portable\IAR\STR75x\portmacro.h"
#endif
#ifdef STR75X_GCC
#include "..\..\Source\portable\GCC\STR75x\portmacro.h"
#endif
#ifdef STR91X_IAR
#include "..\..\Source\portable\IAR\STR91x\portmacro.h"
#endif
#ifdef GCC_H8S
#include "../../Source/portable/GCC/H8S2329/portmacro.h"
#endif
#ifdef GCC_AT91FR40008
#include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h"
#endif
#ifdef RVDS_ARMCM3_LM3S102
#include "../../Source/portable/RVDS/ARM_CM3/portmacro.h"
#endif
#ifdef GCC_ARMCM3_LM3S102
#include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
#endif
#ifdef GCC_ARMCM3
#include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
#endif
#ifdef IAR_ARM_CM3
#include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
#endif
#ifdef IAR_ARMCM3_LM
#include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
#endif
#ifdef HCS12_CODE_WARRIOR
#include "../../Source/portable/CodeWarrior/HCS12/portmacro.h"
#endif
#ifdef MICROBLAZE_GCC
#include "../../Source/portable/GCC/MicroBlaze/portmacro.h"
#endif
#ifdef TERN_EE
#include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h"
#endif
#ifdef GCC_HCS12
#include "../../Source/portable/GCC/HCS12/portmacro.h"
#endif
#ifdef GCC_MCF5235
#include "../../Source/portable/GCC/MCF5235/portmacro.h"
#endif
#ifdef COLDFIRE_V2_GCC
#include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h"
#endif
#ifdef COLDFIRE_V2_CODEWARRIOR
#include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h"
#endif
#ifdef GCC_PPC405
#include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h"
#endif
#ifdef GCC_PPC440
#include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h"
#endif
#ifdef _16FX_SOFTUNE
#include "..\..\Source\portable\Softune\MB96340\portmacro.h"
#endif
#ifdef BCC_INDUSTRIAL_PC_PORT
/* A short file name has to be used in place of the normal
FreeRTOSConfig.h when using the Borland compiler. */
#include "frconfig.h"
#include "..\portable\BCC\16BitDOS\PC\prtmacro.h"
typedef void ( __interrupt __far *pxISR )();
#endif
#ifdef BCC_FLASH_LITE_186_PORT
/* A short file name has to be used in place of the normal
FreeRTOSConfig.h when using the Borland compiler. */
#include "frconfig.h"
#include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h"
typedef void ( __interrupt __far *pxISR )();
#endif
#ifdef __GNUC__
#ifdef __AVR32_AVR32A__
#include "portmacro.h"
#endif
#endif
#ifdef __ICCAVR32__
#ifdef __CORE__
#if __CORE__ == __AVR32A__
#include "portmacro.h"
#endif
#endif
#endif
#ifdef __91467D
#include "portmacro.h"
#endif
#ifdef __96340
#include "portmacro.h"
#endif
#ifdef __IAR_V850ES_Fx3__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_V850ES_Jx3__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_V850ES_Jx3_L__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_V850ES_Jx2__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_V850ES_Hx2__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_78K0R_Kx3__
#include "../../Source/portable/IAR/78K0R/portmacro.h"
#endif
#ifdef __IAR_78K0R_Kx3L__
#include "../../Source/portable/IAR/78K0R/portmacro.h"
#endif
#endif /* DEPRECATED_DEFINITIONS_H */

View File

@@ -42,58 +42,58 @@ Purely for reasons of backward compatibility the old method is still valid, but
to make it clear that new projects should not use it, support for the port
specific constants has been moved into the deprecated_definitions.h header
file. */
#include "deprecated_definitions.h"
/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
did not result in a portmacro.h header file being included - and it should be
included here. In this case the path to the correct portmacro.h header file
must be set in the compiler's include path. */
#ifndef portENTER_CRITICAL
#include "portmacro.h"
#include "portmacro.h"
#endif
#if portBYTE_ALIGNMENT == 32
#define portBYTE_ALIGNMENT_MASK ( 0x001f )
#define portBYTE_ALIGNMENT_MASK (0x001f)
#endif
#if portBYTE_ALIGNMENT == 16
#define portBYTE_ALIGNMENT_MASK ( 0x000f )
#define portBYTE_ALIGNMENT_MASK (0x000f)
#endif
#if portBYTE_ALIGNMENT == 8
#define portBYTE_ALIGNMENT_MASK ( 0x0007 )
#define portBYTE_ALIGNMENT_MASK (0x0007)
#endif
#if portBYTE_ALIGNMENT == 4
#define portBYTE_ALIGNMENT_MASK ( 0x0003 )
#define portBYTE_ALIGNMENT_MASK (0x0003)
#endif
#if portBYTE_ALIGNMENT == 2
#define portBYTE_ALIGNMENT_MASK ( 0x0001 )
#define portBYTE_ALIGNMENT_MASK (0x0001)
#endif
#if portBYTE_ALIGNMENT == 1
#define portBYTE_ALIGNMENT_MASK ( 0x0000 )
#define portBYTE_ALIGNMENT_MASK (0x0000)
#endif
#ifndef portBYTE_ALIGNMENT_MASK
#error "Invalid portBYTE_ALIGNMENT definition"
#error "Invalid portBYTE_ALIGNMENT definition"
#endif
#ifndef portNUM_CONFIGURABLE_REGIONS
#define portNUM_CONFIGURABLE_REGIONS 1
#define portNUM_CONFIGURABLE_REGIONS 1
#endif
#ifndef portHAS_STACK_OVERFLOW_CHECKING
#define portHAS_STACK_OVERFLOW_CHECKING 0
#define portHAS_STACK_OVERFLOW_CHECKING 0
#endif
#ifndef portARCH_NAME
#define portARCH_NAME NULL
#define portARCH_NAME NULL
#endif
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include "mpu_wrappers.h"
@@ -104,41 +104,41 @@ extern "C" {
* the order that the port expects to find them.
*
*/
#if( portUSING_MPU_WRAPPERS == 1 )
#if( portHAS_STACK_OVERFLOW_CHECKING == 1 )
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
#else
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
#endif
#if (portUSING_MPU_WRAPPERS == 1)
#if (portHAS_STACK_OVERFLOW_CHECKING == 1)
StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged) PRIVILEGED_FUNCTION;
#else
#if( portHAS_STACK_OVERFLOW_CHECKING == 1 )
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION;
#else
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION;
#endif
StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged) PRIVILEGED_FUNCTION;
#endif
#else
#if (portHAS_STACK_OVERFLOW_CHECKING == 1)
StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters) PRIVILEGED_FUNCTION;
#else
StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters) PRIVILEGED_FUNCTION;
#endif
#endif
/* Used by heap_5.c to define the start address and size of each memory region
/* Used by heap_5.c to define the start address and size of each memory region
that together comprise the total FreeRTOS heap space. */
typedef struct HeapRegion
{
uint8_t *pucStartAddress;
size_t xSizeInBytes;
} HeapRegion_t;
typedef struct HeapRegion
{
uint8_t *pucStartAddress;
size_t xSizeInBytes;
} HeapRegion_t;
/* Used to pass information about the heap out of vPortGetHeapStats(). */
typedef struct xHeapStats
{
size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */
size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */
size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */
size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */
size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */
} HeapStats_t;
/* Used to pass information about the heap out of vPortGetHeapStats(). */
typedef struct xHeapStats
{
size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */
size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */
size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */
size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */
size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */
} HeapStats_t;
/*
/*
* Used to define multiple heap regions for use by heap_5.c. This function
* must be called before any calls to pvPortMalloc() - not creating a task,
* queue, semaphore, mutex, software timer, event group, etc. will result in
@@ -149,35 +149,35 @@ typedef struct xHeapStats
* terminated by a HeapRegions_t structure that has a size of 0. The region
* with the lowest start address must appear first in the array.
*/
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
void vPortDefineHeapRegions(const HeapRegion_t *const pxHeapRegions) PRIVILEGED_FUNCTION;
/*
/*
* Returns a HeapStats_t structure filled with information about the current
* heap state.
*/
void vPortGetHeapStats( HeapStats_t *pxHeapStats );
void vPortGetHeapStats(HeapStats_t *pxHeapStats);
/*
/*
* Map to the memory management routines required for the port.
*/
void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
void *pvPortMalloc(size_t xSize) PRIVILEGED_FUNCTION;
void vPortFree(void *pv) PRIVILEGED_FUNCTION;
void vPortInitialiseBlocks(void) PRIVILEGED_FUNCTION;
size_t xPortGetFreeHeapSize(void) PRIVILEGED_FUNCTION;
size_t xPortGetMinimumEverFreeHeapSize(void) PRIVILEGED_FUNCTION;
/*
/*
* Setup the hardware ready for the scheduler to take control. This generally
* sets up a tick interrupt and sets timers for the correct tick frequency.
*/
BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
BaseType_t xPortStartScheduler(void) PRIVILEGED_FUNCTION;
/*
/*
* Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
* the hardware is left in its original condition after the scheduler stops
* executing.
*/
void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
void vPortEndScheduler(void) PRIVILEGED_FUNCTION;
/*
* The structures and methods of manipulating the MPU are contained within the
@@ -186,9 +186,9 @@ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
* Fills the xMPUSettings structure with the memory region information
* contained in xRegions.
*/
#if( portUSING_MPU_WRAPPERS == 1 )
#if (portUSING_MPU_WRAPPERS == 1)
struct xMEMORY_REGION;
void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION;
void vPortStoreTaskMPUSettings(xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION *const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth) PRIVILEGED_FUNCTION;
#endif
#ifdef __cplusplus
@@ -196,4 +196,3 @@ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
#endif
#endif /* PORTABLE_H */

View File

@@ -13,22 +13,22 @@
* Default soldering temp is 320.0 C
* Temperature the iron sleeps at - default 150.0 C
*/
#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C
#define SLEEP_TEMP 150 // Default sleep temperature
#define BOOST_TEMP 420 // Default boost temp.
#define BOOST_MODE_ENABLED 1 // 0: Disable 1: Enable
#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C
#define SLEEP_TEMP 150 // Default sleep temperature
#define BOOST_TEMP 420 // Default boost temp.
#define BOOST_MODE_ENABLED 1 // 0: Disable 1: Enable
/**
* Blink the temperature on the cooling screen when its > 50C
*/
#define COOLING_TEMP_BLINK 0 // 0: Disable 1: Enable
#define COOLING_TEMP_BLINK 0 // 0: Disable 1: Enable
/**
* How many seconds/minutes we wait until going to sleep/shutdown.
* Values -> SLEEP_TIME * 10; i.e. 5*10 = 50 Seconds!
*/
#define SLEEP_TIME 5 // x10 Seconds
#define SHUTDOWN_TIME 10 // Minutes
#define SLEEP_TIME 5 // x10 Seconds
#define SHUTDOWN_TIME 10 // Minutes
/**
* Auto start off for safety.
@@ -38,22 +38,22 @@
* 2 - Sleep Temperature
* 3 - Sleep Off Temperature
*/
#define AUTO_START_MODE 0 // Default to none
#define AUTO_START_MODE 0 // Default to none
/**
* OLED Orientation
*
*/
#define ORIENTATION_MODE 0 // 0: Right 1:Left 2:Automatic - Default right
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperatur change
#define ORIENTATION_MODE 0 // 0: Right 1:Left 2:Automatic - Default right
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperatur change
/**
* Temp change settings
*/
#define TEMP_CHANGE_SHORT_STEP 1 // Default temp change short step +1
#define TEMP_CHANGE_LONG_STEP 10 // Default temp change long step +10
#define TEMP_CHANGE_SHORT_STEP_MAX 50 // Temp change short step MAX value
#define TEMP_CHANGE_LONG_STEP_MAX 100 // Temp change long step MAX value
#define TEMP_CHANGE_SHORT_STEP 1 // Default temp change short step +1
#define TEMP_CHANGE_LONG_STEP 10 // Default temp change long step +10
#define TEMP_CHANGE_SHORT_STEP_MAX 50 // Temp change short step MAX value
#define TEMP_CHANGE_LONG_STEP_MAX 100 // Temp change long step MAX value
/* Power pulse for keeping power banks awake*/
#define POWER_PULSE_INCREMENT 1
@@ -68,70 +68,83 @@
* OLED Orientation Sensitivity on Automatic mode!
* Motion Sensitivity <0=Off 1=Least Sensitive 9=Most Sensitive>
*/
#define SENSITIVITY 7 // Default 7
#define SENSITIVITY 7 // Default 7
/**
* Detailed soldering screen
* Detailed idle screen (off for first time users)
*/
#define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0
#define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0
#define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0
#define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0
#define CUT_OUT_SETTING 0 // default to no cut-off voltage (or 18W for TS80)
#define TEMPERATURE_INF 0 // default to 0
#define DESCRIPTION_SCROLL_SPEED 0 // 0: Slow 1: Fast - default to slow
#define POWER_LIMIT_ENABLE 0 // 0: Disable 1: Enable - Default disabled power limit
#define CUT_OUT_SETTING 0 // default to no cut-off voltage (or 18W for TS80)
#define TEMPERATURE_INF 0 // default to 0
#define DESCRIPTION_SCROLL_SPEED 0 // 0: Slow 1: Fast - default to slow
#define POWER_LIMIT_ENABLE 0 // 0: Disable 1: Enable - Default disabled power limit
#define TIP_GAIN 210 // 21 uV/C * 10, uV per deg C constant of the tip, Tip uV * 10 / coeff = tip temp
#define TIP_GAIN 210 // 21 uV/C * 10, uV per deg C constant of the tip, Tip uV * 10 / coeff = tip temp
#define OP_AMP_Rf_TS100 750*1000 // 750 Kilo-ohms -> From schematic, R1
#define OP_AMP_Rin_TS100 2370 // 2.37 Kilo-ohms -> From schematic, R2
#define OP_AMP_Rf_TS100 750 * 1000 // 750 Kilo-ohms -> From schematic, R1
#define OP_AMP_Rin_TS100 2370 // 2.37 Kilo-ohms -> From schematic, R2
#define OP_AMP_GAIN_STAGE_TS100 (1+(OP_AMP_Rf_TS100/OP_AMP_Rin_TS100))
#define OP_AMP_GAIN_STAGE_TS100 (1 + (OP_AMP_Rf_TS100 / OP_AMP_Rin_TS100))
#define OP_AMP_Rf_TS80 180*1000 // 180 Kilo-ohms -> From schematic, R6
#define OP_AMP_Rin_TS80 2000 // 2.0 Kilo-ohms -> From schematic, R3
#define OP_AMP_Rf_TS80 180 * 1000 // 180 Kilo-ohms -> From schematic, R6
#define OP_AMP_Rin_TS80 2000 // 2.0 Kilo-ohms -> From schematic, R3
#define OP_AMP_GAIN_STAGE_TS80 (1+(OP_AMP_Rf_TS80/OP_AMP_Rin_TS80))
#define OP_AMP_GAIN_STAGE_TS80 (1 + (OP_AMP_Rf_TS80 / OP_AMP_Rin_TS80))
//Deriving the Voltage div:
// Vin_max = (3.3*(r1+r2))/(r2)
//vdiv = (32768*4)/(vin_max*10)
#ifdef MODEL_TS100
#define VOLTAGE_DIV 467 // 467 - Default divider from schematic
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
#define PID_POWER_LIMIT 70 // Sets the max pwm power limit
#define POWER_LIMIT 30 // 30 watts default limit
#define MAX_POWER_LIMIT 65 //
#define POWER_LIMIT_STEPS 5 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100
#define VOLTAGE_DIV 467 // 467 - Default divider from schematic
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
#define PID_POWER_LIMIT 70 // Sets the max pwm power limit
#define POWER_LIMIT 30 // 30 watts default limit
#define MAX_POWER_LIMIT 65 //
#define POWER_LIMIT_STEPS 5 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100
#endif
#ifdef MODEL_Pinecil
#define VOLTAGE_DIV 467 // 467 - Default divider from schematic
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
#define PID_POWER_LIMIT 70 // Sets the max pwm power limit
#define POWER_LIMIT 30 // 30 watts default limit
#define MAX_POWER_LIMIT 65 //
#define POWER_LIMIT_STEPS 5 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100
#endif
#ifdef MODEL_TS80
#define VOLTAGE_DIV 780 // Default divider from schematic
#define PID_POWER_LIMIT 24 // Sets the max pwm power limit
#define CALIBRATION_OFFSET 900 // the adc offset in uV
#define POWER_LIMIT 24 // 24 watts default power limit
#define MAX_POWER_LIMIT 30 //
#define POWER_LIMIT_STEPS 2
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80
#define VOLTAGE_DIV 780 // Default divider from schematic
#define PID_POWER_LIMIT 24 // Sets the max pwm power limit
#define CALIBRATION_OFFSET 900 // the adc offset in uV
#define POWER_LIMIT 24 // 24 watts default power limit
#define MAX_POWER_LIMIT 30 //
#define POWER_LIMIT_STEPS 2
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80
#endif
#ifdef MODEL_TS80P
#define VOLTAGE_DIV 650 // Default for TS80P with slightly different resistors
#define PID_POWER_LIMIT 35 // Sets the max pwm power limit
#define CALIBRATION_OFFSET 900 // the adc offset in uV
#define POWER_LIMIT 30 // 30 watts default power limit
#define MAX_POWER_LIMIT 35 //
#define POWER_LIMIT_STEPS 2
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80
#define VOLTAGE_DIV 650 // Default for TS80P with slightly different resistors
#define PID_POWER_LIMIT 35 // Sets the max pwm power limit
#define CALIBRATION_OFFSET 900 // the adc offset in uV
#define POWER_LIMIT 30 // 30 watts default power limit
#define MAX_POWER_LIMIT 35 //
#define POWER_LIMIT_STEPS 2
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80
#endif
#ifdef MODEL_TS100
const int32_t tipMass = 45; // X10 watts to raise 1 deg C in 1 second
const int32_t tipMass = 45; // X10 watts to raise 1 deg C in 1 second
const uint8_t tipResistance = 85; //x10 ohms, 8.5 typical for ts100, 4.5 typical for ts80
#endif
#ifdef MODEL_Pinecil
const int32_t tipMass = 45; // X10 watts to raise 1 deg C in 1 second
const uint8_t tipResistance = 85; //x10 ohms, 8.5 typical for ts100, 4.5 typical for ts80
#endif