mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
[simu] Updates for RTOS abstraction layer; Remove further SIMU_SLEEP usages.
This commit is contained in:
parent
a2006940db
commit
66cd99bf6b
8 changed files with 28 additions and 36 deletions
|
@ -61,7 +61,6 @@
|
|||
#define CONVERT_PTR_UINT(x) ((uint32_t)(uint64_t)(x))
|
||||
#define CONVERT_UINT_PTR(x) ((uint32_t*)(uint64_t)(x))
|
||||
#else
|
||||
#define SIMU_SLEEP(x) true
|
||||
#define CONVERT_PTR_UINT(x) ((uint32_t)(x))
|
||||
#define CONVERT_UINT_PTR(x) ((uint32_t *)(x))
|
||||
#endif
|
||||
|
|
|
@ -61,8 +61,11 @@ void bootloaderFlash(const char * filename)
|
|||
flashWrite(CONVERT_UINT_PTR(FIRMWARE_ADDRESS+i+j), (uint32_t *)(buffer+j));
|
||||
}
|
||||
drawProgressBar(STR_WRITING, i, BOOTLOADER_SIZE);
|
||||
if (!SIMU_SLEEP(30/*ms*/))
|
||||
#if defined(SIMU)
|
||||
// add an artificial delay and check for simu quit
|
||||
if (SIMU_SLEEP_OR_EXIT_MS(30))
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (unlocked) {
|
||||
|
|
|
@ -123,7 +123,8 @@ void sportProcessUpdatePacket(uint8_t * packet)
|
|||
bool sportWaitState(SportUpdateState state, int timeout)
|
||||
{
|
||||
#if defined(SIMU)
|
||||
SIMU_SLEEP(1);
|
||||
UNUSED(state);
|
||||
UNUSED(timeout);
|
||||
return true;
|
||||
#else
|
||||
watchdogSuspend(timeout / 10);
|
||||
|
|
|
@ -33,19 +33,8 @@ extern "C++" {
|
|||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#if __GNUC__
|
||||
#include <unistd.h>
|
||||
static inline void msleep(unsigned x)
|
||||
{
|
||||
usleep(1000 * x);
|
||||
}
|
||||
#else
|
||||
#include <windows.h>
|
||||
inline void msleep(unsigned x)
|
||||
{
|
||||
Sleep(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SIMU_SLEEP_OR_EXIT_MS(x) simuSleep(x)
|
||||
|
||||
typedef pthread_t RTOS_TASK_HANDLE;
|
||||
typedef pthread_mutex_t RTOS_MUTEX_HANDLE;
|
||||
|
@ -53,6 +42,7 @@ extern "C++" {
|
|||
typedef sem_t * RTOS_EVENT_HANDLE;
|
||||
|
||||
extern uint64_t simuTimerMicros(void);
|
||||
extern uint8_t simuSleep(uint32_t ms);
|
||||
|
||||
static inline void RTOS_INIT()
|
||||
{
|
||||
|
@ -62,14 +52,14 @@ extern "C++" {
|
|||
{
|
||||
}
|
||||
|
||||
static inline void RTOS_WAIT_MS(unsigned x)
|
||||
static inline void RTOS_WAIT_MS(uint32_t x)
|
||||
{
|
||||
msleep(x);
|
||||
simuSleep(x);
|
||||
}
|
||||
|
||||
static inline void RTOS_WAIT_TICKS(unsigned x)
|
||||
static inline void RTOS_WAIT_TICKS(uint32_t x)
|
||||
{
|
||||
msleep(x * 2);
|
||||
RTOS_WAIT_MS(x * 2);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -125,7 +115,7 @@ extern "C++" {
|
|||
#define TASK_FUNCTION(task) void * task(void * pdata)
|
||||
|
||||
template<int SIZE>
|
||||
inline void RTOS_CREATE_TASK(pthread_t &taskId, void * task(void *), const char * name, FakeTaskStack<SIZE> &stack, unsigned stackSize, unsigned priority)
|
||||
inline void RTOS_CREATE_TASK(pthread_t &taskId, void * task(void *), const char *, FakeTaskStack<SIZE> &, unsigned, unsigned)
|
||||
{
|
||||
pthread_create(&taskId, nullptr, task, nullptr);
|
||||
}
|
||||
|
@ -176,7 +166,7 @@ extern "C++" {
|
|||
CoStartOS();
|
||||
}
|
||||
|
||||
static inline void RTOS_WAIT_MS(unsigned x)
|
||||
static inline void RTOS_WAIT_MS(uint32_t x)
|
||||
{
|
||||
if (!x)
|
||||
return;
|
||||
|
@ -185,7 +175,7 @@ extern "C++" {
|
|||
CoTickDelay(x);
|
||||
}
|
||||
|
||||
static inline void RTOS_WAIT_TICKS(unsigned x)
|
||||
static inline void RTOS_WAIT_TICKS(uint32_t x)
|
||||
{
|
||||
CoTickDelay(x);
|
||||
}
|
||||
|
|
|
@ -63,12 +63,12 @@ uint8_t eepromWriteBuffer[EEPROM_BUFFER_SIZE] __DMA;
|
|||
|
||||
void eepromWaitReadStatus()
|
||||
{
|
||||
while (eepromReadStatus() == 0 && SIMU_SLEEP(5/*ms*/)) { }
|
||||
while (!eepromReadStatus()) { }
|
||||
}
|
||||
|
||||
void eepromWaitTransferComplete()
|
||||
{
|
||||
while (!eepromIsTransferComplete() && SIMU_SLEEP(5/*ms*/)) { }
|
||||
while (!eepromIsTransferComplete()) { }
|
||||
}
|
||||
|
||||
void eepromEraseBlock(uint32_t address, bool blocking=true)
|
||||
|
|
|
@ -911,8 +911,11 @@ void eepromBackup()
|
|||
eepromReadBlock(buffer, i, 1024);
|
||||
f_write(&file, buffer, 1024, &count);
|
||||
drawProgressBar(STR_WRITING, i, EEPROM_SIZE);
|
||||
if (!SIMU_SLEEP(100/*ms*/))
|
||||
#if defined(SIMU)
|
||||
// add an artificial delay and check for simu quit
|
||||
if (SIMU_SLEEP_OR_EXIT_MS(100))
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
f_close(&file);
|
||||
|
|
|
@ -398,14 +398,14 @@ bool simuIsRunning()
|
|||
return simu_running;
|
||||
}
|
||||
|
||||
bool simuSleep(uint32_t ms)
|
||||
uint8_t simuSleep(uint32_t ms)
|
||||
{
|
||||
for (uint32_t i = 0; i < ms; ++i){
|
||||
if (simu_shutdown || !simu_running)
|
||||
return false;
|
||||
return 1;
|
||||
sleep(1);
|
||||
}
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audioConsumeCurrentBuffer()
|
||||
|
|
|
@ -232,11 +232,7 @@ extern char * main_thread_error;
|
|||
|
||||
#define OPENTX_START_DEFAULT_ARGS simu_start_mode
|
||||
|
||||
static inline void getADC()
|
||||
{
|
||||
}
|
||||
|
||||
#define SIMU_SLEEP(x) simuSleep(x)
|
||||
static inline void getADC() { }
|
||||
|
||||
uint64_t simuTimerMicros(void);
|
||||
|
||||
|
@ -244,7 +240,7 @@ void simuInit();
|
|||
void StartSimu(bool tests=true, const char * sdPath = 0, const char * settingsPath = 0);
|
||||
void StopSimu();
|
||||
bool simuIsRunning();
|
||||
bool simuSleep(uint32_t ms);
|
||||
uint8_t simuSleep(uint32_t ms); // returns true if thread shutdown requested
|
||||
|
||||
void simuSetKey(uint8_t key, bool state);
|
||||
void simuSetTrim(uint8_t trim, bool state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue