chore: New module/serial API (#3055)
* WiP: new module interface * WiP: softserial timer DMA * WiP: setup() and send() in one step and remove methods specific to internal or external module * fixes and extra port config * horus targets * module ports have moved * T8 support (only internal module) * fix nv14 * stupid GCC.... * disable BT * remove nv14 telem driver * remove old aux serial driver * Move module buffers out of pulses.h * Soft serial fixes and PXX1 support * Fixed PPM module output * Fixed CLI * compilation fixes * Ported bluetooth and flysky gimbal to new serial driver * Re-enable soft-serial RX * fixes and cleanup * nv14 fixes * Fix flysky gimbals * Ghost module * 16 bytes of RAM * Remove getByte from module API * Ghost cleanup * fix: _half_duplex_input() must be called after usart init * WiP * more cleanup * Remove board specific settings from PXX1 / PXX2 drivers * A bit of PXX2 header cleanup * Add support for OVER8 and ONEBIT * Add some support for inverters (NV14 / EL18) * Support NV14 power fixes in generic board * Fix polarity handling * Fix RX DMA * Fix mixer not running * Add soft-serial polarity control * Quick fix for telemetry polling while module port is changed * Fix bootloader DEBUG * Fix MPM telemetry * Fix pulse start * DSM2 soft-serial fallback * DSMP async module restart * Fix CRSF LUA upstream * Remove global variable telemetryProtocol * Use HAL/LL constants * Fix various issue with AFHDS3 and NV14/EL18 internal module * Fixed S.PORT unit tests * fix: update widx after writing at current index * fix: init error condition * Fix: possible infinite loop in _find_port() * Add support for bidir S.PORT init * Add support for "getLastByte" in HW serial driver * PXX1: Add support for S.PORT based on IDLE callback * Fix rebase error * Fix softserial _rx_fifo_push() * Add softserial support for waitForTxCompleted() * Fix MPM flashing (internal / external) * Fixed external MPM * Activate RX DMA on internal module Seems to work with serial passthrough without issues, at least on the L3R PRO. * Fix softserial DMA on stdlcd F4 targets * Add softserial support for 32bit timers (mostly TIM2) * More precise soft-serial * Fix MPM update using inverters & HW uart * Raise S.PORT DMA/USART IRQ prio to achieve faster switching to input * Remove useless delays * Fix flashing external ELRS module * Added a retry mechanism for FrSky S.PORT update * Remove useless enableRx() * External FrSky modules are all flashed via S.PORT * Remove power management unit update This was only used on the first batch of X-lite.
This commit is contained in:
@@ -53,7 +53,6 @@ volatile uint32_t rotencDt = 0;
|
||||
|
||||
// TODO: remove all STM32 defs
|
||||
GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpioi, gpioj;
|
||||
USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4;
|
||||
ADC_Common_TypeDef adc;
|
||||
RTC_TypeDef rtc;
|
||||
|
||||
@@ -155,7 +154,6 @@ void simuStart(bool tests, const char * sdPath, const char * settingsPath)
|
||||
if (simu_running)
|
||||
return;
|
||||
|
||||
stopPulses();
|
||||
#if !defined(COLORLCD)
|
||||
menuLevel = 0;
|
||||
#endif
|
||||
@@ -233,6 +231,9 @@ void simuStart(bool tests, const char * sdPath, const char * settingsPath)
|
||||
#endif
|
||||
}
|
||||
|
||||
extern RTOS_TASK_HANDLE mixerTaskId;
|
||||
extern RTOS_TASK_HANDLE menusTaskId;
|
||||
|
||||
void simuStop()
|
||||
{
|
||||
if (!simu_running)
|
||||
@@ -569,51 +570,6 @@ void setSelectedUsbMode(int mode) {}
|
||||
void delay_ms(uint32_t ms) { }
|
||||
void delay_us(uint16_t us) { }
|
||||
|
||||
// GPIO fake functions
|
||||
void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF) { }
|
||||
|
||||
// PWR fake functions
|
||||
void PWR_BackupAccessCmd(FunctionalState NewState) { }
|
||||
void PWR_BackupRegulatorCmd(FunctionalState NewState) { }
|
||||
|
||||
// USART fake functions
|
||||
void USART_DeInit(USART_TypeDef* ) { }
|
||||
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct) { }
|
||||
void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState) { }
|
||||
void USART_ClearITPendingBit(USART_TypeDef*, unsigned short) { }
|
||||
void USART_SendData(USART_TypeDef* USARTx, uint16_t Data) { }
|
||||
uint16_t USART_ReceiveData(USART_TypeDef*) { return 0; }
|
||||
void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState) { }
|
||||
void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState) { }
|
||||
FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG) { return SET; }
|
||||
|
||||
// TIM fake functions
|
||||
void TIM_DMAConfig(TIM_TypeDef* TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength) { }
|
||||
void TIM_DMACmd(TIM_TypeDef* TIMx, uint16_t TIM_DMASource, FunctionalState NewState) { }
|
||||
void TIM_CtrlPWMOutputs(TIM_TypeDef* TIMx, FunctionalState NewState) { }
|
||||
|
||||
// SPI fake functions
|
||||
void SPI_I2S_DeInit(SPI_TypeDef* SPIx) { }
|
||||
void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState) { }
|
||||
|
||||
// RCC fake functions
|
||||
void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource) { }
|
||||
void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState) { }
|
||||
void RCC_RTCCLKCmd(FunctionalState NewState) { }
|
||||
void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SR) { }
|
||||
void RCC_PLLI2SCmd(FunctionalState NewState) { }
|
||||
void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource) { }
|
||||
void RCC_LSEConfig(uint8_t RCC_LSE) { }
|
||||
void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks) { };
|
||||
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) { return SET; }
|
||||
|
||||
// EXTI fake functions
|
||||
void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex) { }
|
||||
void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) { }
|
||||
ITStatus EXTI_GetITStatus(uint32_t EXTI_Line) { return RESET; }
|
||||
void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) { }
|
||||
void EXTI_ClearITPendingBit(uint32_t EXTI_Line) { }
|
||||
|
||||
void unlockFlash()
|
||||
{
|
||||
}
|
||||
@@ -717,21 +673,28 @@ const etx_serial_port_t UsbSerialPort = { "USB-VCP", nullptr, nullptr };
|
||||
#endif
|
||||
|
||||
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL)
|
||||
static void* _fake_drv_init(const etx_serial_init*) { return nullptr; }
|
||||
static void* _fake_drv_init(void*, const etx_serial_init*) { return (void*)1; }
|
||||
static void _fake_drv_fct1(void*) {}
|
||||
static void _fake_drv_send_byte(void*, uint8_t) {}
|
||||
static void _fake_drv_send_buffer(void*, const uint8_t*, uint8_t) {}
|
||||
static void _fake_drv_send_buffer(void*, const uint8_t*, uint32_t) {}
|
||||
static int _fake_drv_get_byte(void*, uint8_t*) { return 0; }
|
||||
static const etx_serial_driver_t _fake_drv = {
|
||||
.init = _fake_drv_init,
|
||||
.deinit = _fake_drv_fct1,
|
||||
.sendByte = _fake_drv_send_byte,
|
||||
.sendBuffer = _fake_drv_send_buffer,
|
||||
.waitForTxCompleted = _fake_drv_fct1,
|
||||
.txCompleted = nullptr,
|
||||
.waitForTxCompleted = nullptr,
|
||||
.enableRx = nullptr,
|
||||
.getByte = _fake_drv_get_byte,
|
||||
.getLastByte = nullptr,
|
||||
.clearRxBuffer = nullptr,
|
||||
.getBaudrate = nullptr,
|
||||
.setBaudrate = nullptr,
|
||||
.setPolarity = nullptr,
|
||||
.setHWOption = nullptr,
|
||||
.setReceiveCb = nullptr,
|
||||
.setIdleCb = nullptr,
|
||||
.setBaudrateCb = nullptr,
|
||||
};
|
||||
#endif
|
||||
@@ -743,7 +706,12 @@ static const etx_serial_driver_t _fake_drv = {
|
||||
#else
|
||||
#define AUX_SERIAL_PWR nullptr
|
||||
#endif
|
||||
static const etx_serial_port_t auxSerialPort = {"AUX1", &_fake_drv, AUX_SERIAL_PWR};
|
||||
static const etx_serial_port_t auxSerialPort = {
|
||||
"AUX1",
|
||||
&_fake_drv,
|
||||
nullptr,
|
||||
AUX_SERIAL_PWR
|
||||
};
|
||||
#define AUX_SERIAL_PORT &auxSerialPort
|
||||
#else
|
||||
#define AUX_SERIAL_PORT nullptr
|
||||
@@ -756,7 +724,12 @@ static const etx_serial_port_t auxSerialPort = {"AUX1", &_fake_drv, AUX_SERIAL_P
|
||||
#else
|
||||
#define AUX2_SERIAL_PWR nullptr
|
||||
#endif
|
||||
static const etx_serial_port_t aux2SerialPort = {"AUX2", &_fake_drv, AUX2_SERIAL_PWR};
|
||||
static const etx_serial_port_t aux2SerialPort = {
|
||||
"AUX2",
|
||||
&_fake_drv,
|
||||
nullptr,
|
||||
AUX2_SERIAL_PWR
|
||||
};
|
||||
#define AUX2_SERIAL_PORT &aux2SerialPort
|
||||
#else
|
||||
#define AUX2_SERIAL_PORT nullptr
|
||||
|
||||
Reference in New Issue
Block a user