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:
@@ -20,10 +20,14 @@
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "boards/generic_stm32/module_ports.h"
|
||||
#include "boards/generic_stm32/intmodule_heartbeat.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "rtc.h"
|
||||
|
||||
#include "hal/adc_driver.h"
|
||||
#include "hal/module_port.h"
|
||||
#include "stm32_hal_adc.h"
|
||||
|
||||
#include "../common/arm/stm32/timers_driver.h"
|
||||
@@ -32,10 +36,13 @@
|
||||
|
||||
#if !defined(BOOT)
|
||||
#include "opentx.h"
|
||||
#if defined(PXX1)
|
||||
#include "pulses/pxx1.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(AUX_SERIAL)
|
||||
#include "aux_serial_driver.h"
|
||||
#if defined(BLUETOOTH)
|
||||
#include "bluetooth_driver.h"
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@@ -59,37 +66,6 @@ void watchdogInit(unsigned int duration)
|
||||
IWDG->KR = 0xCCCC; // start
|
||||
}
|
||||
|
||||
#if defined(SPORT_UPDATE_PWR_GPIO) && !defined(BOOT)
|
||||
void sportUpdateInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = SPORT_UPDATE_PWR_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(SPORT_UPDATE_PWR_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void sportUpdatePowerOn()
|
||||
{
|
||||
GPIO_SPORT_UPDATE_PWR_GPIO_ON(SPORT_UPDATE_PWR_GPIO, SPORT_UPDATE_PWR_GPIO_PIN);
|
||||
}
|
||||
|
||||
void sportUpdatePowerOff()
|
||||
{
|
||||
GPIO_SPORT_UPDATE_PWR_GPIO_OFF(SPORT_UPDATE_PWR_GPIO, SPORT_UPDATE_PWR_GPIO_PIN);
|
||||
}
|
||||
|
||||
void sportUpdatePowerInit()
|
||||
{
|
||||
if (g_eeGeneral.sportUpdatePower == 1)
|
||||
sportUpdatePowerOn();
|
||||
else
|
||||
sportUpdatePowerOff();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOT)
|
||||
|
||||
#if defined(RADIO_TPRO)
|
||||
@@ -154,13 +130,25 @@ void boardInit()
|
||||
}
|
||||
#endif
|
||||
|
||||
// Sets 'hardwareOption.pcbrev' as well
|
||||
pwrInit();
|
||||
boardInitModulePorts();
|
||||
|
||||
#if defined(AUTOUPDATE)
|
||||
telemetryPortInit(FRSKY_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
|
||||
sportSendByteLoop(0x7E);
|
||||
#if defined(INTERNAL_MODULE_PXX1) && defined(PXX_FREQUENCY_HIGH)
|
||||
pxx1SetInternalBaudrate(PXX1_FAST_SERIAL_BAUDRATE);
|
||||
#endif
|
||||
|
||||
#if defined(INTMODULE_HEARTBEAT) && \
|
||||
(defined(INTERNAL_MODULE_PXX1) || defined(INTERNAL_MODULE_PXX2))
|
||||
pulsesSetModuleInitCb(_intmodule_heartbeat_init);
|
||||
pulsesSetModuleDeInitCb(_intmodule_heartbeat_deinit);
|
||||
#endif
|
||||
|
||||
// #if defined(AUTOUPDATE)
|
||||
// telemetryPortInit(FRSKY_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
|
||||
// sportSendByteLoop(0x7E);
|
||||
// #endif
|
||||
|
||||
#if defined(STATUS_LEDS)
|
||||
ledInit();
|
||||
#if defined(RADIO_T8) || defined(RADIO_COMMANDO8) || defined(RADIO_TLITE) || \
|
||||
@@ -230,7 +218,7 @@ void boardInit()
|
||||
lcdInit(); // delaysInit() must be called before
|
||||
audioInit();
|
||||
init2MhzTimer();
|
||||
init1msTimer();
|
||||
init5msTimer();
|
||||
__enable_irq();
|
||||
usbInit();
|
||||
|
||||
@@ -264,10 +252,6 @@ void boardInit()
|
||||
usbChargerInit();
|
||||
#endif
|
||||
|
||||
if (HAS_SPORT_UPDATE_CONNECTOR()) {
|
||||
sportUpdateInit();
|
||||
}
|
||||
|
||||
#if defined(JACK_DETECT_GPIO)
|
||||
initJackDetect();
|
||||
#endif
|
||||
@@ -402,27 +386,3 @@ void initJackDetect(void)
|
||||
GPIO_Init(JACK_DETECT_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUX_SERIAL)
|
||||
const etx_serial_port_t auxSerialPort = {
|
||||
"AUX1",
|
||||
&AuxSerialDriver,
|
||||
nullptr
|
||||
};
|
||||
#define AUX_SERIAL_PORT &auxSerialPort
|
||||
#else
|
||||
#define AUX_SERIAL_PORT nullptr
|
||||
#endif
|
||||
|
||||
#define AUX2_SERIAL_PORT nullptr
|
||||
|
||||
static const etx_serial_port_t* serialPorts[MAX_AUX_SERIAL] = {
|
||||
AUX_SERIAL_PORT,
|
||||
AUX2_SERIAL_PORT,
|
||||
};
|
||||
|
||||
const etx_serial_port_t* auxSerialGetPort(int port_nr)
|
||||
{
|
||||
if (port_nr >= MAX_AUX_SERIAL) return nullptr;
|
||||
return serialPorts[port_nr];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user