chore: Introduce FreeRTOS Software timers
Introduce FreeRTOS Software timers
This commit is contained in:
@@ -45,8 +45,6 @@ const etx_serial_init afhds2SerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
|
||||
static void* afhds2Init(uint8_t module)
|
||||
|
||||
@@ -111,31 +111,12 @@ static void crossfireSetupMixerScheduler(uint8_t module)
|
||||
}
|
||||
|
||||
#if defined(INTERNAL_MODULE_CRSF)
|
||||
static void intmoduleCRSF_rx(uint8_t data)
|
||||
{
|
||||
intmoduleFifo.push(data);
|
||||
|
||||
#if !defined(SIMU)
|
||||
// wakeup mixer when rx buffer is quarter full (16 bytes)
|
||||
if (intmoduleFifo.size() >= 16) {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
xTaskNotifyFromISR(mixerTaskId.rtos_handle, 0, eNoAction,
|
||||
&xHigherPriorityTaskWoken);
|
||||
|
||||
// might effect a context switch on ISR exit
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static const etx_serial_init intmoduleCrossfireInitParams = {
|
||||
.baudrate = 0,
|
||||
.parity = ETX_Parity_None,
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.on_receive = intmoduleCRSF_rx,
|
||||
.on_error = nullptr,
|
||||
};
|
||||
|
||||
static void* crossfireInitInternal(uint8_t module)
|
||||
@@ -146,9 +127,6 @@ static void* crossfireInitInternal(uint8_t module)
|
||||
etx_serial_init params(intmoduleCrossfireInitParams);
|
||||
params.baudrate = INT_CROSSFIRE_BAUDRATE;
|
||||
|
||||
// wakeup mixer when rx buffer is quarter full (16 bytes)
|
||||
params.on_receive = intmoduleCRSF_rx;
|
||||
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.init(¶ms);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
@@ -60,8 +60,6 @@ etx_serial_init multiSerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_Two,
|
||||
.word_length = ETX_WordLength_9,
|
||||
.rx_enable = true,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -49,12 +49,42 @@
|
||||
#include "pulses/afhds2.h"
|
||||
#endif
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <timers.h>
|
||||
|
||||
uint8_t s_pulses_paused = 0;
|
||||
ModuleState moduleState[NUM_MODULES];
|
||||
InternalModulePulsesData intmodulePulsesData __DMA;
|
||||
ExternalModulePulsesData extmodulePulsesData __DMA;
|
||||
TrainerPulsesData trainerPulsesData __DMA;
|
||||
|
||||
void startPulses()
|
||||
{
|
||||
telemetryStart();
|
||||
s_pulses_paused = false;
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
setupPulsesInternalModule();
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_EXTERNAL_MODULE)
|
||||
setupPulsesExternalModule();
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_EXTRA_MODULE)
|
||||
extramodulePpmStart();
|
||||
#endif
|
||||
}
|
||||
|
||||
void stopPulses()
|
||||
{
|
||||
telemetryStop();
|
||||
s_pulses_paused = true;
|
||||
|
||||
for (uint8_t i = 0; i < NUM_MODULES; i++)
|
||||
moduleState[i].protocol = PROTOCOL_CHANNELS_UNINITIALIZED;
|
||||
}
|
||||
|
||||
void restartModule(uint8_t idx)
|
||||
{
|
||||
if (idx == INTERNAL_MODULE) {
|
||||
|
||||
@@ -262,29 +262,8 @@ uint8_t actualAfhdsRunPower(int moduleIndex);
|
||||
#endif
|
||||
void extramodulePpmStart();
|
||||
|
||||
inline void startPulses()
|
||||
{
|
||||
s_pulses_paused = false;
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
setupPulsesInternalModule();
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_EXTERNAL_MODULE)
|
||||
setupPulsesExternalModule();
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_EXTRA_MODULE)
|
||||
extramodulePpmStart();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void stopPulses()
|
||||
{
|
||||
s_pulses_paused = true;
|
||||
for (uint8_t i = 0; i < NUM_MODULES; i++)
|
||||
moduleState[i].protocol = PROTOCOL_CHANNELS_UNINITIALIZED;
|
||||
}
|
||||
void startPulses();
|
||||
void stopPulses();
|
||||
|
||||
inline bool pulsesStarted()
|
||||
{
|
||||
|
||||
@@ -231,8 +231,6 @@ static const etx_serial_init pxx1SerialInit = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = false,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
|
||||
static void* pxx1InitInternal(uint8_t module)
|
||||
@@ -293,8 +291,6 @@ static const etx_serial_init pxx1ExtSerialInit = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = false,
|
||||
.on_receive = extmoduleFifoReceive,
|
||||
.on_error = extmoduleFifoError,
|
||||
};
|
||||
|
||||
static void* pxx1InitExternal(uint8_t module)
|
||||
|
||||
@@ -36,8 +36,6 @@ const etx_serial_init pxx2SerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -717,8 +715,6 @@ static const etx_serial_init pxx2ExtSerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.on_receive = extmoduleFifoReceive,
|
||||
.on_error = extmoduleFifoError,
|
||||
};
|
||||
|
||||
static void* pxx2InitLowSpeed(uint8_t module)
|
||||
|
||||
Reference in New Issue
Block a user