RTOS refactoring + more AVR removal
This commit is contained in:
@@ -95,9 +95,6 @@ extern "C" {
|
||||
#define TIMER_MULT_APB1 2
|
||||
#define TIMER_MULT_APB2 2
|
||||
|
||||
#define strcpy_P strcpy
|
||||
#define strcat_P strcat
|
||||
|
||||
extern uint16_t sessionTimer;
|
||||
|
||||
#define SLAVE_MODE() (g_model.trainerMode == TRAINER_MODE_SLAVE)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
/* Lock / unlock functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
#if !defined(BOOT)
|
||||
static OS_MutexID ioMutex;
|
||||
static RTOS_MUTEX_HANDLE ioMutex;
|
||||
uint32_t ioMutexReq = 0, ioMutexRel = 0;
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
{
|
||||
@@ -44,13 +44,14 @@ int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
int ff_req_grant (_SYNC_t mutex)
|
||||
{
|
||||
ioMutexReq += 1;
|
||||
return CoEnterMutexSection(mutex) == E_OK;
|
||||
RTOS_LOCK_MUTEX(mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ff_rel_grant (_SYNC_t mutex)
|
||||
{
|
||||
ioMutexRel += 1;
|
||||
CoLeaveMutexSection(mutex);
|
||||
RTOS_UNLOCK_MUTEX(mutex);
|
||||
}
|
||||
|
||||
int ff_del_syncobj (_SYNC_t mutex)
|
||||
|
||||
@@ -49,7 +49,7 @@ uint32_t Peri1_frequency, Peri2_frequency;
|
||||
GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpioi, gpioj;
|
||||
TIM_TypeDef tim1, tim2, tim3, tim4, tim5, tim6, tim7, tim8, tim9, tim10;
|
||||
RCC_TypeDef rcc;
|
||||
DMA_Stream_TypeDef dma1_stream2, dma1_stream5, dma1_stream7, dma2_stream1, dma2_stream2, dma2_stream5, dma2_stream6, dma2_stream7;
|
||||
DMA_Stream_TypeDef dma1_stream1, dma1_stream2, dma1_stream3, dma1_stream4, dma1_stream5, dma1_stream6, dma1_stream7, dma2_stream1, dma2_stream2, dma2_stream5, dma2_stream6, dma2_stream7;
|
||||
DMA_TypeDef dma2;
|
||||
USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4;
|
||||
SysTick_Type systick;
|
||||
@@ -105,7 +105,7 @@ uint64_t simuTimerMicros(void)
|
||||
#else // GNUC
|
||||
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
return (U64) std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
return (uint64_t) std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -121,7 +121,7 @@ uint16_t getTmr2MHz()
|
||||
}
|
||||
|
||||
// return 2ms resolution to match CoOS settings
|
||||
U64 CoGetOSTime(void)
|
||||
uint64_t CoGetOSTime(void)
|
||||
{
|
||||
return simuTimerMicros() / 2000;
|
||||
}
|
||||
@@ -524,11 +524,6 @@ void StopAudioThread()
|
||||
}
|
||||
#endif // #if defined(SIMU_AUDIO)
|
||||
|
||||
uint16_t stackAvailable()
|
||||
{
|
||||
return 500;
|
||||
}
|
||||
|
||||
bool simuLcdRefresh = true;
|
||||
display_t simuLcdBuf[DISPLAY_BUFFER_SIZE];
|
||||
|
||||
@@ -666,18 +661,3 @@ void LCD_ControlLight(uint16_t dutyCycle) { }
|
||||
void serialPrintf(const char * format, ...) { }
|
||||
void serialCrlf() { }
|
||||
void serialPutc(char c) { }
|
||||
uint16_t stackSize() { return 0; }
|
||||
|
||||
void * start_routine(void * attr)
|
||||
{
|
||||
FUNCPtr task = (FUNCPtr)attr;
|
||||
task(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OS_TID CoCreateTask(FUNCPtr task, void *argv, uint32_t parameter, void * stk, uint32_t stksize)
|
||||
{
|
||||
pthread_t tid;
|
||||
pthread_create(&tid, NULL, start_routine, (void *)task);
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ extern GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpio
|
||||
extern TIM_TypeDef tim1, tim2, tim3, tim4, tim5, tim6, tim7, tim8, tim9, tim10;
|
||||
extern USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4;
|
||||
extern RCC_TypeDef rcc;
|
||||
extern DMA_Stream_TypeDef dma1_stream2, dma1_stream5, dma1_stream7, dma2_stream1, dma2_stream2, dma2_stream5, dma2_stream6, dma2_stream7;
|
||||
extern DMA_Stream_TypeDef dma1_stream0, dma1_stream1, dma1_stream2, dma1_stream3, dma1_stream4, dma1_stream5, dma1_stream6, dma1_stream7, dma2_stream1, dma2_stream2, dma2_stream5, dma2_stream6, dma2_stream7;
|
||||
extern DMA_TypeDef dma2;
|
||||
extern SysTick_Type systick;
|
||||
#undef SysTick
|
||||
@@ -147,7 +147,11 @@ extern SysTick_Type systick;
|
||||
#define USART3 (&Usart3)
|
||||
#undef RCC
|
||||
#define RCC (&rcc)
|
||||
#undef DMA1_Stream0
|
||||
#undef DMA1_Stream1
|
||||
#undef DMA1_Stream2
|
||||
#undef DMA1_Stream3
|
||||
#undef DMA1_Stream4
|
||||
#undef DMA1_Stream5
|
||||
#undef DMA1_Stream7
|
||||
#undef DMA2_Stream1
|
||||
@@ -155,7 +159,11 @@ extern SysTick_Type systick;
|
||||
#undef DMA2_Stream5
|
||||
#undef DMA2_Stream6
|
||||
#undef DMA2_Stream7
|
||||
#define DMA1_Stream0 (&dma1_stream0)
|
||||
#define DMA1_Stream1 (&dma1_stream1)
|
||||
#define DMA1_Stream2 (&dma1_stream2)
|
||||
#define DMA1_Stream3 (&dma1_stream3)
|
||||
#define DMA1_Stream4 (&dma1_stream4)
|
||||
#define DMA1_Stream5 (&dma1_stream5)
|
||||
#define DMA1_Stream7 (&dma1_stream7)
|
||||
#define DMA2_Stream1 (&dma2_stream1)
|
||||
@@ -213,117 +221,6 @@ extern uint32_t txPdcUsart( uint8_t *buffer, uint32_t size );
|
||||
extern uint32_t txPdcPending();
|
||||
extern void rxPdcUsart( void (*pChProcess)(uint8_t x) );
|
||||
|
||||
#define loop_until_bit_is_set( port, bitnum) \
|
||||
while ( 0/*! ( (port) & (1 << (bitnum)) )*/ ) ;
|
||||
|
||||
#define PROGMEM
|
||||
#define pgm_read_byte(address_short) (*(uint8_t*)(address_short))
|
||||
#define pgm_read_word(address_short) (*(uint16_t*)(address_short))
|
||||
#define pgm_read_adr(address_short) *address_short
|
||||
#define pgm_read_stringP(adr) ((adr))
|
||||
#define PSTR(adr) adr
|
||||
#define _delay_us(a)
|
||||
#define _delay_ms(a)
|
||||
#define cli()
|
||||
#define sei()
|
||||
#define strcpy_P strcpy
|
||||
#define strcat_P strcat
|
||||
#define memcpy_P memcpy
|
||||
|
||||
#define PORTA dummyport
|
||||
#define PORTB portb
|
||||
#define PORTC portc
|
||||
#define PORTD dummyport
|
||||
#define PORTE dummyport
|
||||
#define PORTF dummyport
|
||||
#define PORTG dummyport
|
||||
#define PORTH porth
|
||||
#define PORTL dummyport
|
||||
#define DDRA dummyport
|
||||
#define DDRB dummyport
|
||||
#define DDRC dummyport
|
||||
#define DDRD dummyport
|
||||
#define DDRE dummyport
|
||||
#define DDRF dummyport
|
||||
#define DDRG dummyport
|
||||
#define EEMEM
|
||||
|
||||
#define UCSR0B dummyport
|
||||
#define UDRIE0 dummyport
|
||||
#define TXB80 dummyport
|
||||
#define TXCIE0 dummyport
|
||||
#define TXEN0 dummyport
|
||||
#define RXEN0 dummyport
|
||||
#define DDE0 dummyport
|
||||
#define PORTE0 dummyport
|
||||
#define RXCIE0 dummyport
|
||||
#define OCR0A dummyport
|
||||
#define OCR1A dummyport16
|
||||
#define OCR1B dummyport16
|
||||
#define OCR1C dummyport16
|
||||
#define OCR2 dummyport
|
||||
#define OCR3A dummyport16
|
||||
#define OCR3B dummyport16
|
||||
#define OCR4A dummyport
|
||||
#define OCR5A dummyport
|
||||
#define TCCR0A dummyport
|
||||
#define TCCR1A dummyport
|
||||
#define TCCR1B dummyport
|
||||
#define TCCR1C dummyport
|
||||
#define COM1B0 dummyport
|
||||
#define COM0A0 dummyport
|
||||
#define TCNT1 dummyport16
|
||||
#define TCNT1L dummyport
|
||||
#define TCNT5 dummyport16
|
||||
#define ICR1 dummyport16
|
||||
#define TIFR dummyport
|
||||
#define TIFR1 dummyport
|
||||
#define ETIFR dummyport
|
||||
|
||||
#define SPDR dummyport
|
||||
#define SPSR dummyport
|
||||
#define SPIF dummyport
|
||||
#define SPCR dummyport
|
||||
|
||||
#define TIMSK dummyport
|
||||
#define TIMSK1 dummyport
|
||||
#define TIMSK3 dummyport
|
||||
#define TIMSK4 dummyport
|
||||
#define TIMSK5 dummyport
|
||||
#define ETIMSK dummyport
|
||||
#define ETIMSK1 dummyport
|
||||
|
||||
#define UCSZ02 dummyport
|
||||
#define UCSR0C dummyport
|
||||
#define UCSZ01 dummyport
|
||||
#define UCSZ00 dummyport
|
||||
#define UCSR0A dummyport
|
||||
#define RXC0 dummyport
|
||||
|
||||
#define UDR0 dummyport
|
||||
#define OCIE1A dummyport
|
||||
#define OCIE1B dummyport
|
||||
#define OCIE1C dummyport
|
||||
#define OCIE4A dummyport
|
||||
#define OCIE5A dummyport
|
||||
|
||||
#define OUT_B_LIGHT 7
|
||||
#define INP_E_ElevDR 2
|
||||
#define INP_E_Trainer 5
|
||||
#define INP_E_Gear 4
|
||||
#define INP_C_ThrCt 6
|
||||
#define INP_C_AileDR 7
|
||||
#define INP_E_ID2 6
|
||||
|
||||
#define WGM10 0
|
||||
#define WGM12 0
|
||||
#define COM1B1 0
|
||||
#define FOC1B 0
|
||||
#define CS10 0
|
||||
#define DOR0 0
|
||||
#define UPE0 0
|
||||
#define FE0 0
|
||||
|
||||
#define ISR(x, ...) void x()
|
||||
|
||||
#if !defined(_MSC_VER) && defined(__GNUC__)
|
||||
@@ -345,7 +242,6 @@ extern char * main_thread_error;
|
||||
|
||||
#define getADC()
|
||||
#define GET_ADC_IF_MIXER_NOT_RUNNING()
|
||||
#define getADC_bandgap()
|
||||
|
||||
#define SIMU_SLEEP(x) do { if (!main_thread_running) return; sleep(x/*ms*/); } while (0)
|
||||
#define SIMU_SLEEP_NORET(x) do { sleep(x/*ms*/); } while (0)
|
||||
@@ -370,49 +266,12 @@ void StopEepromThread();
|
||||
#define StopAudioThread()
|
||||
#endif
|
||||
|
||||
|
||||
#define OS_MutexID pthread_mutex_t
|
||||
extern OS_MutexID audioMutex;
|
||||
|
||||
#define OS_FlagID uint32_t
|
||||
#define OS_TID pthread_t
|
||||
#define OS_TCID uint32_t
|
||||
#define OS_STK uint32_t
|
||||
|
||||
#define E_OK 0
|
||||
#define WDRF 0
|
||||
|
||||
void * simuMain(void * args = NULL);
|
||||
extern uint8_t MCUCSR, MCUSR, MCUCR;
|
||||
|
||||
typedef unsigned int U32;
|
||||
typedef unsigned long long U64;
|
||||
typedef void (*FUNCPtr)(void*);
|
||||
|
||||
#define CoInitOS(...)
|
||||
#define CoStartOS(...)
|
||||
|
||||
OS_TID CoCreateTask(FUNCPtr task, void *argv, uint32_t parameter, void * stk, uint32_t stksize);
|
||||
#define CoCreateTaskEx(...) 0
|
||||
|
||||
#define CoCreateMutex(...) PTHREAD_MUTEX_INITIALIZER
|
||||
#define CoEnterMutexSection(m) pthread_mutex_lock(&(m))
|
||||
#define CoLeaveMutexSection(m) pthread_mutex_unlock(&(m))
|
||||
|
||||
#define CoSetFlag(...)
|
||||
#define CoClearFlag(...)
|
||||
#define CoSetTmrCnt(...)
|
||||
#define CoEnterISR(...)
|
||||
#define CoExitISR(...)
|
||||
#define CoStartTmr(...)
|
||||
#define CoWaitForSingleFlag(...) 0
|
||||
#define CoTickDelay(x) sleep(2*(x))
|
||||
#define CoCreateFlag(...) 0
|
||||
U64 CoGetOSTime(void);
|
||||
|
||||
#define UART_Stop(...)
|
||||
#define UART3_Stop(...)
|
||||
#define USART_GetITStatus(...) 0
|
||||
#define USART_ClearFlag(...)
|
||||
|
||||
#if defined(STM32)
|
||||
inline void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) { }
|
||||
@@ -437,6 +296,7 @@ inline void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_Init
|
||||
inline void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState) { }
|
||||
inline void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct) { }
|
||||
inline void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState) { }
|
||||
void DMACopy(void * src, void * dest, unsigned size);
|
||||
inline FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG) { return RESET; }
|
||||
inline ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT) { return RESET; }
|
||||
inline void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT) { }
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
FILE * diskImage = 0;
|
||||
FATFS g_FATFS_Obj = {0};
|
||||
|
||||
OS_MutexID ioMutex;
|
||||
RTOS_MUTEX_HANDLE ioMutex;
|
||||
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj) /* Create a sync object */
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ void btSendBuffer()
|
||||
btTx.buffer = btTxBuffer;
|
||||
txPdcBt(&btTx);
|
||||
while (btTx.ready == 1) {
|
||||
CoTickDelay(1); // 2ms for now
|
||||
RTOS_WAIT_TICKS(1);
|
||||
}
|
||||
btTx.size = 0;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ uint32_t btChangeBaudrate( uint32_t baudIndex )
|
||||
}
|
||||
}
|
||||
else {
|
||||
CoTickDelay(1) ; // 2mS
|
||||
RTOS_WAIT_TICKS(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ uint32_t btPollDevice()
|
||||
}
|
||||
}
|
||||
else {
|
||||
CoTickDelay(1) ; // 2mS
|
||||
RTOS_WAIT_TICKS(1) ; // 2mS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ void bluetoothTask(void * pdata)
|
||||
x = 0 ;
|
||||
}
|
||||
btSetBaudrate(x) ;
|
||||
CoTickDelay(1) ; // 2mS
|
||||
RTOS_WAIT_TICKS(1) ; // 2mS
|
||||
btStatus = btPollDevice() ; // Do we get a response?
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,7 @@ void bluetoothTask(void * pdata)
|
||||
btInit();
|
||||
}
|
||||
|
||||
CoTickDelay(1) ;
|
||||
RTOS_WAIT_TICKS(1) ;
|
||||
|
||||
btPollDevice(); // Do we get a response?
|
||||
|
||||
|
||||
@@ -223,9 +223,6 @@ extern uint8_t temperature ; // Raw temp reading
|
||||
extern uint8_t maxTemperature ; // Raw temp reading
|
||||
uint8_t getTemperature();
|
||||
|
||||
#define strcpy_P strcpy
|
||||
#define strcat_P strcat
|
||||
|
||||
#if !defined(REVA)
|
||||
extern uint16_t Current_analogue;
|
||||
extern uint16_t Current_max;
|
||||
|
||||
@@ -79,7 +79,7 @@ uint32_t transSpeed;
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if !defined(BOOT)
|
||||
static OS_MutexID ioMutex;
|
||||
static RTOS_MUTEX_HANDLE ioMutex;
|
||||
volatile int mutexCheck = 0;
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
{
|
||||
@@ -89,7 +89,7 @@ int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
|
||||
int ff_req_grant (_SYNC_t mutex)
|
||||
{
|
||||
CoEnterMutexSection(mutex);
|
||||
RTOS_LOCK_MUTEX(mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ const char * sdIdentify()
|
||||
* The host that does not support CMD8 shall supply high voltage range... */
|
||||
result = sdCmd8(1);
|
||||
if (result == 0) f8 = 1;
|
||||
else if (result == SD_NORESPONSE) CoTickDelay(1); /* 2ms delay after "no response" */
|
||||
else if (result == SD_NORESPONSE) RTOS_WAIT_MS(2); /* 2ms delay after "no response" */
|
||||
else return "Identify.8 error";
|
||||
|
||||
#if 0
|
||||
@@ -956,7 +956,7 @@ void sdInit()
|
||||
}
|
||||
|
||||
sdCmd0();
|
||||
CoTickDelay(5); // 10ms
|
||||
RTOS_WAIT_MS(10); // 10ms
|
||||
sdCmd8(1);
|
||||
|
||||
#if 0
|
||||
@@ -971,7 +971,7 @@ void sdInit()
|
||||
uint8_t retry;
|
||||
for (retry=0; retry<10; retry++) {
|
||||
if (!sdCmd2()) break;
|
||||
CoTickDelay(1); // 2ms
|
||||
RTOS_WAIT_MS(2); // 2ms
|
||||
}
|
||||
|
||||
if (retry == 10) {
|
||||
@@ -982,7 +982,7 @@ void sdInit()
|
||||
|
||||
for (retry=0; retry<10; retry++) {
|
||||
if (!sdCmd3()) break;
|
||||
CoTickDelay(1); // 2ms
|
||||
RTOS_WAIT_MS(2); // 2ms
|
||||
}
|
||||
|
||||
if (retry == 10) {
|
||||
|
||||
@@ -107,10 +107,10 @@ extern "C" void INTERRUPT_xMS_IRQHandler()
|
||||
#endif
|
||||
|
||||
#if (defined(PCBX9E) && !defined(SIMU))
|
||||
const pm_uchar bmp_startup[] PROGMEM = {
|
||||
const pm_uchar bmp_startup[] = {
|
||||
#include "startup.lbm"
|
||||
};
|
||||
const pm_uchar bmp_lock[] PROGMEM = {
|
||||
const pm_uchar bmp_lock[] = {
|
||||
#include "lock.lbm"
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -106,9 +106,6 @@ extern "C" {
|
||||
#define TIMER_MULT_APB1 2
|
||||
#define TIMER_MULT_APB2 2
|
||||
|
||||
#define strcpy_P strcpy
|
||||
#define strcat_P strcat
|
||||
|
||||
extern uint16_t sessionTimer;
|
||||
|
||||
// Board driver
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
/* Lock / unlock functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
#if !defined(BOOT)
|
||||
static OS_MutexID ioMutex;
|
||||
static RTOS_MUTEX_HANDLE ioMutex;
|
||||
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
{
|
||||
@@ -70,12 +70,13 @@ int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
|
||||
int ff_req_grant (_SYNC_t mutex)
|
||||
{
|
||||
return CoEnterMutexSection(mutex) == E_OK;
|
||||
RTOS_LOCK_MUTEX(mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ff_rel_grant (_SYNC_t mutex)
|
||||
{
|
||||
CoLeaveMutexSection(mutex);
|
||||
RTOS_UNLOCK_MUTEX(mutex);
|
||||
}
|
||||
|
||||
int ff_del_syncobj (_SYNC_t mutex)
|
||||
|
||||
Reference in New Issue
Block a user