WiP internal module buffer
This commit is contained in:
@@ -1059,8 +1059,6 @@ static const etx_serial_init spIntmoduleSerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
|
||||
static void spInternalModuleSetBaudRate(uint32_t baud)
|
||||
|
||||
@@ -47,8 +47,6 @@ typedef struct {
|
||||
uint8_t word_length; // = ETX_WordLength_8;
|
||||
uint8_t rx_enable; // = false;
|
||||
|
||||
void (*on_receive)(uint8_t data); // = nullptr;
|
||||
void (*on_error)(); // = nullptr;
|
||||
} etx_serial_init;
|
||||
|
||||
struct etx_serial_callbacks_t {
|
||||
|
||||
@@ -316,8 +316,6 @@ static const etx_serial_init serialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
#ifndef _IO_PXX2_H_
|
||||
#define _IO_PXX2_H_
|
||||
|
||||
#include "../fifo.h"
|
||||
#include "../pulses/pxx.h"
|
||||
#include "fifo.h"
|
||||
#include "pulses/pxx.h"
|
||||
|
||||
#include "board.h"
|
||||
|
||||
class ModuleFifo : public Fifo<uint8_t, INTMODULE_FIFO_SIZE> {
|
||||
public:
|
||||
|
||||
@@ -82,8 +82,6 @@ static const etx_serial_init serialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
|
||||
class MultiInternalUpdateDriver: public MultiFirmwareUpdateDriver
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -290,8 +290,6 @@ void serialInit(uint8_t port_nr, int mode)
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = false,
|
||||
.on_receive = nullptr,
|
||||
.on_error = nullptr,
|
||||
};
|
||||
|
||||
bool power_required = false;
|
||||
|
||||
@@ -52,7 +52,7 @@ static void* aux_serial_init(const SerialState* st, const etx_serial_init* param
|
||||
{
|
||||
stm32_usart_init(st->usart, params);
|
||||
|
||||
if (params->rx_enable && st->usart->rxDMA && !params->on_receive) {
|
||||
if (params->rx_enable && st->usart->rxDMA) {
|
||||
st->rxFifo->clear();
|
||||
stm32_usart_init_rx_dma(st->usart, st->rxFifo->buffer(), st->rxFifo->size());
|
||||
}
|
||||
|
||||
@@ -38,19 +38,12 @@ void extmoduleFifoReceive(uint8_t data)
|
||||
extmoduleFifo.push(data);
|
||||
}
|
||||
|
||||
void extmoduleFifoError()
|
||||
{
|
||||
extmoduleFifo.errors++;
|
||||
}
|
||||
|
||||
static const etx_serial_init extmoduleSerialParams = {
|
||||
.baudrate = 0,
|
||||
.parity = ETX_Parity_None,
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.on_receive = extmoduleFifoReceive,
|
||||
.on_error = extmoduleFifoError,
|
||||
};
|
||||
|
||||
static const LL_GPIO_InitTypeDef extmoduleUSART_PinDef = {
|
||||
@@ -80,8 +73,8 @@ static void* extmoduleSerialStart(const etx_serial_init* params)
|
||||
{
|
||||
if (!params) return nullptr;
|
||||
|
||||
extmodule_driver.on_receive = params->on_receive;
|
||||
extmodule_driver.on_error = params->on_error;
|
||||
extmodule_driver.on_receive = extmoduleFifoReceive;
|
||||
extmodule_driver.on_error = nullptr;
|
||||
|
||||
// UART config
|
||||
stm32_usart_init(&extmoduleUSART, params);
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#include "intmodule_serial_driver.h"
|
||||
#include "stm32_usart_driver.h"
|
||||
#include "board.h"
|
||||
#include "fifo.h"
|
||||
|
||||
#include "io/frsky_pxx2.h"
|
||||
ModuleFifo intmoduleFifo;
|
||||
Fifo<uint8_t, INTMODULE_FIFO_SIZE> intmoduleFifo;
|
||||
|
||||
#if !defined(INTMODULE_DMA_STREAM)
|
||||
static uint8_t * intmoduleTxBufferData;
|
||||
@@ -54,16 +54,11 @@ static etx_serial_callbacks_t intmodule_driver = {
|
||||
};
|
||||
|
||||
// TODO: move this somewhere else
|
||||
void intmoduleFifoReceive(uint8_t data)
|
||||
static void intmoduleFifoReceive(uint8_t data)
|
||||
{
|
||||
intmoduleFifo.push(data);
|
||||
}
|
||||
|
||||
void intmoduleFifoError()
|
||||
{
|
||||
intmoduleFifo.errors++;
|
||||
}
|
||||
|
||||
static const LL_GPIO_InitTypeDef intmoduleUSART_PinDef = {
|
||||
.Pin = INTMODULE_TX_GPIO_PIN | INTMODULE_RX_GPIO_PIN,
|
||||
.Mode = LL_GPIO_MODE_ALTERNATE,
|
||||
@@ -110,8 +105,8 @@ void* intmoduleSerialStart(const etx_serial_init* params)
|
||||
// - the UART seems to block when initialised with baudrate = 0
|
||||
|
||||
// init callbacks
|
||||
intmodule_driver.on_receive = params->on_receive;
|
||||
intmodule_driver.on_error = params->on_error;
|
||||
intmodule_driver.on_receive = intmoduleFifoReceive;
|
||||
intmodule_driver.on_error = nullptr;
|
||||
|
||||
stm32_usart_init(&intmoduleUSART, params);
|
||||
return nullptr;
|
||||
|
||||
@@ -26,8 +26,4 @@
|
||||
|
||||
#define INTMODULE_USART_IRQ_PRIORITY 6
|
||||
|
||||
// Callbacks using intmoduleFifo
|
||||
void intmoduleFifoReceive(uint8_t data);
|
||||
void intmoduleFifoError();
|
||||
|
||||
extern const etx_serial_driver_t IntmoduleSerialDriver;
|
||||
|
||||
@@ -67,8 +67,7 @@ static void interrupt1ms()
|
||||
#endif
|
||||
|
||||
// 5ms loop
|
||||
if (pre_scale == 5 || pre_scale == 10)
|
||||
{
|
||||
if (pre_scale == 5 || pre_scale == 10) {
|
||||
#if defined(HAPTIC)
|
||||
DEBUG_TIMER_START(debugTimerHaptic);
|
||||
HAPTIC_HEARTBEAT();
|
||||
@@ -77,8 +76,7 @@ static void interrupt1ms()
|
||||
}
|
||||
|
||||
// 10ms loop
|
||||
if (pre_scale == 10)
|
||||
{
|
||||
if (pre_scale == 10) {
|
||||
pre_scale = 0;
|
||||
DEBUG_TIMER_START(debugTimerPer10ms);
|
||||
DEBUG_TIMER_SAMPLE(debugTimerPer10msPeriod);
|
||||
|
||||
@@ -615,6 +615,7 @@ int32_t getVolume();
|
||||
#define VOLUME_LEVEL_DEF 12
|
||||
|
||||
// Telemetry driver
|
||||
#define INTMODULE_FIFO_SIZE 512
|
||||
#define TELEMETRY_FIFO_SIZE 512
|
||||
void telemetryPortInit(uint32_t baudrate, uint8_t mode);
|
||||
void telemetryPortSetDirectionInput();
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "intmodule_serial_driver.h"
|
||||
#endif
|
||||
|
||||
static_assert(PXX2_FRAME_MAXLENGTH <= INTMODULE_FIFO_SIZE);
|
||||
|
||||
void processGetHardwareInfoFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_GET_HARDWARE_INFO) {
|
||||
|
||||
@@ -275,6 +275,9 @@ void telemetryWakeup()
|
||||
{
|
||||
uint8_t requiredTelemetryProtocol = modelTelemetryProtocol();
|
||||
|
||||
// TODO: needs to be moved to protocol/module init
|
||||
// as-is, it implies only ONE telemetry protocol
|
||||
// enabled at the same time
|
||||
if (telemetryProtocol != requiredTelemetryProtocol) {
|
||||
telemetryInit(requiredTelemetryProtocol);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user