mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
Follow ups
This commit is contained in:
parent
060b18dbd7
commit
f436f4bbe4
9 changed files with 34 additions and 30 deletions
|
@ -528,7 +528,7 @@ if(NOT MSVC)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DRTOS_COOS)
|
add_definitions(-DFREE_RTOS)
|
||||||
|
|
||||||
add_executable(firmware ${SRC} ${FIRMWARE_HEADERS})
|
add_executable(firmware ${SRC} ${FIRMWARE_HEADERS})
|
||||||
link_libraries(firmware -lstdc++)
|
link_libraries(firmware -lstdc++)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "timers.h"
|
#include "../timers.h"
|
||||||
|
|
||||||
#if (defined(PCBX9E) || defined(PCBX9DP)) && defined(LCD_DUAL_BUFFER)
|
#if (defined(PCBX9E) || defined(PCBX9DP)) && defined(LCD_DUAL_BUFFER)
|
||||||
display_t displayBuf1[DISPLAY_BUFFER_SIZE] __DMA;
|
display_t displayBuf1[DISPLAY_BUFFER_SIZE] __DMA;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "lua_api.h"
|
#include "lua_api.h"
|
||||||
#include "timers.h"
|
#include "../timers.h"
|
||||||
|
|
||||||
/*luadoc
|
/*luadoc
|
||||||
@function model.getInfo()
|
@function model.getInfo()
|
||||||
|
|
|
@ -2090,10 +2090,12 @@ int main()
|
||||||
initialise_monitor_handles();
|
initialise_monitor_handles();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(STM32)
|
||||||
|
#if !defined(SIMU)
|
||||||
/* Ensure all priority bits are assigned as preemption priority bits. */
|
/* Ensure all priority bits are assigned as preemption priority bits. */
|
||||||
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );
|
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(STM32)
|
|
||||||
TRACE("reusableBuffer: modelSel=%d, moduleSetup=%d, calib=%d, sdManager=%d, hardwareAndSettings=%d, spectrumAnalyser=%d, usb=%d",
|
TRACE("reusableBuffer: modelSel=%d, moduleSetup=%d, calib=%d, sdManager=%d, hardwareAndSettings=%d, spectrumAnalyser=%d, usb=%d",
|
||||||
sizeof(reusableBuffer.modelsel),
|
sizeof(reusableBuffer.modelsel),
|
||||||
sizeof(reusableBuffer.moduleSetup),
|
sizeof(reusableBuffer.moduleSetup),
|
||||||
|
|
|
@ -22,13 +22,14 @@
|
||||||
#define _RTOS_H_
|
#define _RTOS_H_
|
||||||
|
|
||||||
#include "definitions.h"
|
#include "definitions.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C++" {
|
extern "C++" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
#define SIMU_SLEEP_OR_EXIT_MS(x) simuSleep(x)
|
#define SIMU_SLEEP_OR_EXIT_MS(x) simuSleep(x)
|
||||||
|
@ -98,9 +99,9 @@ extern "C++" {
|
||||||
};
|
};
|
||||||
#define RTOS_DEFINE_STACK(name, size) FakeTaskStack<size> name
|
#define RTOS_DEFINE_STACK(name, size) FakeTaskStack<size> name
|
||||||
|
|
||||||
#define TASK_FUNCTION(task) void task(void *)
|
#define TASK_FUNCTION(task) void* task(void *)
|
||||||
|
|
||||||
inline void RTOS_CREATE_TASK(pthread_t &taskId, void * task(void *), const char * name)
|
inline void RTOS_CREATE_TASK(pthread_t &taskId, void * (*task)(void *), const char * name)
|
||||||
{
|
{
|
||||||
pthread_create(&taskId, nullptr, task, nullptr);
|
pthread_create(&taskId, nullptr, task, nullptr);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -109,7 +110,7 @@ extern "C++" {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int SIZE>
|
template<int SIZE>
|
||||||
inline void RTOS_CREATE_TASK(pthread_t &taskId, void * task(void *), const char * name, FakeTaskStack<SIZE> &, unsigned size = 0, unsigned priority = 0)
|
inline void RTOS_CREATE_TASK(pthread_t &taskId, void * (*task)(void *), const char * name, FakeTaskStack<SIZE> &, unsigned size = 0, unsigned priority = 0)
|
||||||
{
|
{
|
||||||
UNUSED(size);
|
UNUSED(size);
|
||||||
UNUSED(priority);
|
UNUSED(priority);
|
||||||
|
@ -135,7 +136,7 @@ template<int SIZE>
|
||||||
return (uint32_t)(simuTimerMicros() / 1000);
|
return (uint32_t)(simuTimerMicros() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(RTOS_COOS)
|
#elif defined(FREE_RTOS)
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -158,10 +159,8 @@ template<int SIZE>
|
||||||
StaticSemaphore_t mutex_struct;
|
StaticSemaphore_t mutex_struct;
|
||||||
} RTOS_MUTEX_HANDLE;
|
} RTOS_MUTEX_HANDLE;
|
||||||
|
|
||||||
|
|
||||||
typedef RTOS_MUTEX_HANDLE RTOS_FLAG_HANDLE;
|
typedef RTOS_MUTEX_HANDLE RTOS_FLAG_HANDLE;
|
||||||
|
|
||||||
|
|
||||||
static inline void RTOS_START()
|
static inline void RTOS_START()
|
||||||
{
|
{
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
@ -197,8 +196,6 @@ template<int SIZE>
|
||||||
#define RTOS_CREATE_TASK(h,task,name,stackStruct,stackSize,prio) \
|
#define RTOS_CREATE_TASK(h,task,name,stackStruct,stackSize,prio) \
|
||||||
_RTOS_CREATE_TASK(&h,task,name,stackStruct.stack,stackSize,prio)
|
_RTOS_CREATE_TASK(&h,task,name,stackStruct.stack,stackSize,prio)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline void _RTOS_CREATE_MUTEX(RTOS_MUTEX_HANDLE* h)
|
static inline void _RTOS_CREATE_MUTEX(RTOS_MUTEX_HANDLE* h)
|
||||||
{
|
{
|
||||||
h->rtos_handle = xSemaphoreCreateBinaryStatic(&h->mutex_struct);
|
h->rtos_handle = xSemaphoreCreateBinaryStatic(&h->mutex_struct);
|
||||||
|
@ -310,27 +307,28 @@ template<int SIZE>
|
||||||
return (RTOS_GET_TIME() * RTOS_MS_PER_TICK);
|
return (RTOS_GET_TIME() * RTOS_MS_PER_TICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RTOS_DEFINE_STACK(name, size) TaskStack<size> __ALIGNED(8) name // stack must be aligned to 8 bytes otherwise printf for %f does not work!
|
// stack must be aligned to 8 bytes otherwise printf for %f does not work!
|
||||||
|
#define RTOS_DEFINE_STACK(name, size) TaskStack<size> __ALIGNED(8) name
|
||||||
|
|
||||||
#define TASK_FUNCTION(task) void task(void *)
|
#define TASK_FUNCTION(task) void task(void *)
|
||||||
#define TASK_RETURN() return
|
#define TASK_RETURN() vTaskDelete(nullptr)
|
||||||
|
|
||||||
#else // no RTOS
|
#else // no RTOS
|
||||||
static inline void RTOS_START()
|
static inline void RTOS_START()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void RTOS_WAIT_MS(unsigned x)
|
static inline void RTOS_WAIT_MS(unsigned x)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void RTOS_WAIT_TICKS(unsigned x)
|
static inline void RTOS_WAIT_TICKS(unsigned x)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif // RTOS type
|
#endif // RTOS type
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _RTOS_H_
|
#endif // _RTOS_H_
|
|
@ -22,7 +22,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "timers.h"
|
#include "../timers.h"
|
||||||
|
|
||||||
void eeLoadModel(uint8_t index)
|
void eeLoadModel(uint8_t index)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "timers.h"
|
#include "../timers.h"
|
||||||
#include "conversions/conversions.h"
|
#include "conversions/conversions.h"
|
||||||
|
|
||||||
uint8_t s_write_err = 0; // error reasons
|
uint8_t s_write_err = 0; // error reasons
|
||||||
|
|
|
@ -22,15 +22,12 @@
|
||||||
#include "mixer_scheduler.h"
|
#include "mixer_scheduler.h"
|
||||||
|
|
||||||
RTOS_TASK_HANDLE menusTaskId;
|
RTOS_TASK_HANDLE menusTaskId;
|
||||||
StaticTask_t menusTaskStruct;
|
|
||||||
RTOS_DEFINE_STACK(menusStack, MENUS_STACK_SIZE);
|
RTOS_DEFINE_STACK(menusStack, MENUS_STACK_SIZE);
|
||||||
|
|
||||||
RTOS_TASK_HANDLE mixerTaskId;
|
RTOS_TASK_HANDLE mixerTaskId;
|
||||||
StaticTask_t mixerTaskStruct;
|
|
||||||
RTOS_DEFINE_STACK(mixerStack, MIXER_STACK_SIZE);
|
RTOS_DEFINE_STACK(mixerStack, MIXER_STACK_SIZE);
|
||||||
|
|
||||||
RTOS_TASK_HANDLE audioTaskId;
|
RTOS_TASK_HANDLE audioTaskId;
|
||||||
StaticTask_t audioTaskStruct;
|
|
||||||
RTOS_DEFINE_STACK(audioStack, AUDIO_STACK_SIZE);
|
RTOS_DEFINE_STACK(audioStack, AUDIO_STACK_SIZE);
|
||||||
|
|
||||||
RTOS_MUTEX_HANDLE audioMutex;
|
RTOS_MUTEX_HANDLE audioMutex;
|
||||||
|
|
|
@ -33,10 +33,17 @@
|
||||||
#define AUDIO_STACK_SIZE 400
|
#define AUDIO_STACK_SIZE 400
|
||||||
#define CLI_STACK_SIZE 1000 // only consumed with CLI build option
|
#define CLI_STACK_SIZE 1000 // only consumed with CLI build option
|
||||||
|
|
||||||
|
#if defined(FREE_RTOS)
|
||||||
#define MIXER_TASK_PRIO (tskIDLE_PRIORITY + 4)
|
#define MIXER_TASK_PRIO (tskIDLE_PRIORITY + 4)
|
||||||
#define AUDIO_TASK_PRIO (tskIDLE_PRIORITY + 2)
|
#define AUDIO_TASK_PRIO (tskIDLE_PRIORITY + 2)
|
||||||
#define MENUS_TASK_PRIO (tskIDLE_PRIORITY + 1)
|
#define MENUS_TASK_PRIO (tskIDLE_PRIORITY + 1)
|
||||||
#define CLI_TASK_PRIO (tskIDLE_PRIORITY + 1)
|
#define CLI_TASK_PRIO (tskIDLE_PRIORITY + 1)
|
||||||
|
#else
|
||||||
|
#define MIXER_TASK_PRIO (4)
|
||||||
|
#define AUDIO_TASK_PRIO (2)
|
||||||
|
#define MENUS_TASK_PRIO (1)
|
||||||
|
#define CLI_TASK_PRIO (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
extern RTOS_TASK_HANDLE menusTaskId;
|
extern RTOS_TASK_HANDLE menusTaskId;
|
||||||
extern RTOS_DEFINE_STACK(menusStack, MENUS_STACK_SIZE);
|
extern RTOS_DEFINE_STACK(menusStack, MENUS_STACK_SIZE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue