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:
@@ -19,13 +19,13 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "stm32_hal_ll.h"
|
||||
#include "board.h"
|
||||
#include "boards/generic_stm32/module_ports.h"
|
||||
#include "boards/generic_stm32/intmodule_heartbeat.h"
|
||||
|
||||
#include "hal/adc_driver.h"
|
||||
#include "hal/serial_driver.h"
|
||||
#include "hal/serial_port.h"
|
||||
#include "hal/trainer_driver.h"
|
||||
|
||||
#include "board.h"
|
||||
#include "timers_driver.h"
|
||||
#include "dataconstants.h"
|
||||
#include "opentx_types.h"
|
||||
@@ -35,10 +35,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL)
|
||||
#include "aux_serial_driver.h"
|
||||
#endif
|
||||
|
||||
#if !defined(PCBX12S)
|
||||
#include "stm32_hal_adc.h"
|
||||
#define ADC_DRIVER stm32_hal_adc_driver
|
||||
@@ -47,9 +43,9 @@
|
||||
#define ADC_DRIVER x12s_adc_driver
|
||||
#endif
|
||||
|
||||
extern void flysky_hall_stick_check_init(void);
|
||||
extern void flysky_hall_stick_init(void);
|
||||
extern void flysky_hall_stick_loop( void );
|
||||
#if defined(RADIO_FAMILY_T16) || defined(PCBNV14)
|
||||
#include "flysky_gimbal_driver.h"
|
||||
#endif
|
||||
|
||||
HardwareOptions hardwareOptions;
|
||||
bool boardBacklightOn = false;
|
||||
@@ -64,41 +60,9 @@ void watchdogInit(unsigned int duration)
|
||||
IWDG->KR = 0xCCCC; // start
|
||||
}
|
||||
|
||||
#if HAS_SPORT_UPDATE_CONNECTOR() && !defined(BOOT)
|
||||
|
||||
// g_eeGeneral
|
||||
#if !defined(BOOT)
|
||||
#include "opentx.h"
|
||||
|
||||
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_SetBits(SPORT_UPDATE_PWR_GPIO, SPORT_UPDATE_PWR_GPIO_PIN);
|
||||
}
|
||||
|
||||
void sportUpdatePowerOff()
|
||||
{
|
||||
GPIO_ResetBits(SPORT_UPDATE_PWR_GPIO, SPORT_UPDATE_PWR_GPIO_PIN);
|
||||
}
|
||||
|
||||
void sportUpdatePowerInit()
|
||||
{
|
||||
if (g_eeGeneral.sportUpdatePower == 1)
|
||||
sportUpdatePowerOn();
|
||||
else
|
||||
sportUpdatePowerOff();
|
||||
}
|
||||
#endif
|
||||
|
||||
void boardInit()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph |
|
||||
@@ -160,6 +124,14 @@ void boardInit()
|
||||
#endif
|
||||
|
||||
pwrInit();
|
||||
boardInitModulePorts();
|
||||
|
||||
#if defined(INTMODULE_HEARTBEAT) && \
|
||||
(defined(INTERNAL_MODULE_PXX1) || defined(INTERNAL_MODULE_PXX2))
|
||||
pulsesSetModuleInitCb(_intmodule_heartbeat_init);
|
||||
pulsesSetModuleDeInitCb(_intmodule_heartbeat_deinit);
|
||||
#endif
|
||||
|
||||
init_trainer();
|
||||
pwrOn();
|
||||
delaysInit();
|
||||
@@ -186,34 +158,18 @@ void boardInit()
|
||||
}
|
||||
#endif
|
||||
|
||||
globalData.flyskygimbals = false;
|
||||
#if defined(RADIO_FAMILY_T16) || defined(PCBNV14)
|
||||
flysky_hall_stick_check_init();
|
||||
|
||||
// Wait 70ms for FlySky gimbals to respond. According to LA trace, minimally 23ms is required
|
||||
for (uint8_t ui8 = 0; ui8 < 70; ui8++)
|
||||
{
|
||||
flysky_hall_stick_loop();
|
||||
delay_ms(1);
|
||||
if (globalData.flyskygimbals)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
globalData.flyskygimbals = flysky_gimbal_init();
|
||||
#else
|
||||
globalData.flyskygimbals = false;
|
||||
#endif
|
||||
|
||||
if (globalData.flyskygimbals)
|
||||
{
|
||||
flysky_hall_stick_init();
|
||||
}
|
||||
|
||||
if (!adcInit(&ADC_DRIVER))
|
||||
TRACE("adcInit failed");
|
||||
|
||||
TRACE("adcInit failed");
|
||||
|
||||
init2MhzTimer();
|
||||
init1msTimer();
|
||||
init5msTimer();
|
||||
|
||||
usbInit();
|
||||
hapticInit();
|
||||
|
||||
@@ -232,10 +188,6 @@ void boardInit()
|
||||
usbChargerInit();
|
||||
#endif
|
||||
|
||||
#if HAS_SPORT_UPDATE_CONNECTOR() && !defined(BOOT)
|
||||
sportUpdateInit();
|
||||
#endif
|
||||
|
||||
#if defined(RTCLOCK) && !defined(COPROCESSOR)
|
||||
ledRed();
|
||||
rtcInit(); // RTC must be initialized before rambackupRestore() is called
|
||||
@@ -243,6 +195,7 @@ void boardInit()
|
||||
|
||||
ledBlue();
|
||||
}
|
||||
#endif
|
||||
|
||||
void boardOff()
|
||||
{
|
||||
@@ -305,73 +258,3 @@ bool isBacklightEnabled()
|
||||
return boardBacklightOn;
|
||||
}
|
||||
|
||||
#if defined(AUX_SERIAL_PWR_GPIO) || defined(AUX2_SERIAL_PWR_GPIO)
|
||||
static void _aux_pwr(GPIO_TypeDef *GPIOx, uint32_t pin, uint8_t on)
|
||||
{
|
||||
LL_GPIO_InitTypeDef pinInit;
|
||||
LL_GPIO_StructInit(&pinInit);
|
||||
pinInit.Pin = pin;
|
||||
pinInit.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
pinInit.Pull = LL_GPIO_PULL_UP;
|
||||
LL_GPIO_Init(GPIOx, &pinInit);
|
||||
|
||||
if (on) {
|
||||
LL_GPIO_SetOutputPin(GPIOx, pin);
|
||||
} else {
|
||||
LL_GPIO_ResetOutputPin(GPIOx, pin);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUX_SERIAL)
|
||||
void set_aux_pwr(uint8_t on)
|
||||
{
|
||||
#if defined(AUX_SERIAL_PWR_GPIO)
|
||||
_aux_pwr(AUX_SERIAL_PWR_GPIO, AUX_SERIAL_PWR_GPIO_PIN, on);
|
||||
#endif
|
||||
}
|
||||
|
||||
const etx_serial_port_t auxSerialPort = {
|
||||
"AUX1",
|
||||
&AuxSerialDriver,
|
||||
set_aux_pwr,
|
||||
};
|
||||
#define AUX_SERIAL_PORT &auxSerialPort
|
||||
#else
|
||||
#define AUX_SERIAL_PORT nullptr
|
||||
#endif
|
||||
|
||||
#if defined(AUX2_SERIAL)
|
||||
void set_aux2_pwr(uint8_t on)
|
||||
{
|
||||
#if defined(AUX2_SERIAL_PWR_GPIO)
|
||||
_aux_pwr(AUX2_SERIAL_PWR_GPIO, AUX2_SERIAL_PWR_GPIO_PIN, on);
|
||||
#endif
|
||||
}
|
||||
|
||||
const etx_serial_port_t aux2SerialPort = {
|
||||
#if !defined(PCBX12S)
|
||||
"AUX2",
|
||||
#else
|
||||
// AUX2 is hardwired to the internal GPS
|
||||
// on the X12S, let's hide the setting
|
||||
nullptr,
|
||||
#endif
|
||||
&Aux2SerialDriver,
|
||||
set_aux2_pwr,
|
||||
};
|
||||
#define AUX2_SERIAL_PORT &aux2SerialPort
|
||||
#else
|
||||
#define AUX2_SERIAL_PORT nullptr
|
||||
#endif // AUX2_SERIAL
|
||||
|
||||
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