chore(radio): small board cleanup (#6169)
This commit is contained in:
@@ -29,9 +29,16 @@
|
|||||||
#include "trainer_driver.h"
|
#include "trainer_driver.h"
|
||||||
|
|
||||||
#include "module_ports.h"
|
#include "module_ports.h"
|
||||||
|
#include "intmodule_heartbeat.h"
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "dataconstants.h"
|
#include "dataconstants.h"
|
||||||
|
|
||||||
|
#include "pulses/pulses.h"
|
||||||
|
#include "pulses/pxx1.h"
|
||||||
|
|
||||||
|
#include "trainer.h"
|
||||||
|
|
||||||
#if defined (HARDWARE_INTERNAL_MODULE)
|
#if defined (HARDWARE_INTERNAL_MODULE)
|
||||||
#if defined(INTMODULE_USART)
|
#if defined(INTMODULE_USART)
|
||||||
|
|
||||||
@@ -616,6 +623,17 @@ void boardInitModulePorts()
|
|||||||
gpio_set(EXTMODULE_PWR_FIX_GPIO);
|
gpio_set(EXTMODULE_PWR_FIX_GPIO);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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);
|
||||||
|
trainerSetChangeCb(_intmodule_heartbeat_trainer_hook);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_MODULES()
|
BEGIN_MODULES()
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
#include "definitions.h"
|
#include "definitions.h"
|
||||||
#include "dataconstants.h"
|
#include "dataconstants.h"
|
||||||
#include "pulses_common.h"
|
#include "pulses_common.h"
|
||||||
#include "modules_helpers.h"
|
|
||||||
#include "hal/module_driver.h"
|
#include "hal/module_driver.h"
|
||||||
|
|
||||||
#if defined(PXX2)
|
#if defined(PXX2)
|
||||||
@@ -32,6 +31,10 @@
|
|||||||
#include "pxx2_ota.h"
|
#include "pxx2_ota.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MULTIMODULE)
|
||||||
|
#include "telemetry/multi.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(DSM2)
|
#if defined(DSM2)
|
||||||
#define IS_DSM2_PROTOCOL(protocol) (protocol>=PROTOCOL_CHANNELS_DSM2_LP45 && protocol<=PROTOCOL_CHANNELS_DSM2_DSMX)
|
#define IS_DSM2_PROTOCOL(protocol) (protocol>=PROTOCOL_CHANNELS_DSM2_LP45 && protocol<=PROTOCOL_CHANNELS_DSM2_DSMX)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "edgetx_types.h"
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
#define WRITE_DELAY_10MS 100
|
#define WRITE_DELAY_10MS 100
|
||||||
#elif defined(RTC_BACKUP_RAM)
|
#elif defined(RTC_BACKUP_RAM)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ void setSelectedUsbMode(int mode)
|
|||||||
int usbPlugged()
|
int usbPlugged()
|
||||||
{
|
{
|
||||||
#if defined(DEBUG_DISABLE_USB)
|
#if defined(DEBUG_DISABLE_USB)
|
||||||
return(false);
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t debouncedState = 0;
|
static uint8_t debouncedState = 0;
|
||||||
@@ -135,6 +135,8 @@ void usbInit()
|
|||||||
#else
|
#else
|
||||||
gpio_init(USB_GPIO_VBUS, GPIO_IN, GPIO_PIN_SPEED_LOW);
|
gpio_init(USB_GPIO_VBUS, GPIO_IN, GPIO_PIN_SPEED_LOW);
|
||||||
#endif
|
#endif
|
||||||
|
// prime debounce state...
|
||||||
|
usbPlugged();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: seems this is only needed for USB wakeup,
|
// TODO: seems this is only needed for USB wakeup,
|
||||||
|
|||||||
@@ -141,52 +141,46 @@ uint16_t getSixPosAnalogValue(uint16_t adcValue)
|
|||||||
|
|
||||||
void boardInit()
|
void boardInit()
|
||||||
{
|
{
|
||||||
|
delaysInit();
|
||||||
|
timersInit();
|
||||||
|
__enable_irq();
|
||||||
|
|
||||||
#if defined(RADIO_FAMILY_T16)
|
#if defined(RADIO_FAMILY_T16)
|
||||||
void board_set_bor_level();
|
void board_set_bor_level();
|
||||||
board_set_bor_level();
|
board_set_bor_level();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MANUFACTURER_JUMPER) && defined(FUNCTION_SWITCHES) && !defined(DEBUG)
|
|
||||||
// This is needed to prevent radio from starting when usb is plugged to charge
|
|
||||||
usbInit();
|
usbInit();
|
||||||
// prime debounce state...
|
|
||||||
usbPlugged();
|
#if defined(MANUFACTURER_JUMPER) && defined(FUNCTION_SWITCHES) && \
|
||||||
if (usbPlugged()) {
|
!defined(DEBUG)
|
||||||
delaysInit();
|
// This is needed to prevent radio from starting when usb is plugged to charge
|
||||||
#if defined(AUDIO_MUTE_GPIO)
|
if (usbPlugged()) {
|
||||||
// Charging can make a buzzing noise
|
delaysInit();
|
||||||
gpio_init(AUDIO_MUTE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
#if defined(AUDIO_MUTE_GPIO)
|
||||||
gpio_set(AUDIO_MUTE_GPIO);
|
// Charging can make a buzzing noise
|
||||||
#endif
|
gpio_init(AUDIO_MUTE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||||
while (usbPlugged()) {
|
gpio_set(AUDIO_MUTE_GPIO);
|
||||||
delay_ms(1000);
|
#endif
|
||||||
}
|
while (usbPlugged()) {
|
||||||
while(1) // Wait power to drain
|
delay_ms(1000);
|
||||||
pwrOff();
|
}
|
||||||
}
|
pwrOff();
|
||||||
|
// Wait power to drain
|
||||||
|
while (true) {
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pwrInit();
|
pwrInit();
|
||||||
|
|
||||||
boardInitModulePorts();
|
|
||||||
|
|
||||||
#if defined(INTMODULE_HEARTBEAT) && \
|
|
||||||
(defined(INTERNAL_MODULE_PXX1) || defined(INTERNAL_MODULE_PXX2))
|
|
||||||
pulsesSetModuleInitCb(_intmodule_heartbeat_init);
|
|
||||||
pulsesSetModuleDeInitCb(_intmodule_heartbeat_deinit);
|
|
||||||
trainerSetChangeCb(_intmodule_heartbeat_trainer_hook);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
board_trainer_init();
|
|
||||||
pwrOn();
|
pwrOn();
|
||||||
|
|
||||||
delaysInit();
|
|
||||||
timersInit();
|
|
||||||
__enable_irq();
|
|
||||||
|
|
||||||
TRACE("\nHorus board started :)");
|
TRACE("\nHorus board started :)");
|
||||||
TRACE("RCC->CSR = %08x", RCC->CSR);
|
TRACE("RCC->CSR = %08x", RCC->CSR);
|
||||||
|
|
||||||
|
boardInitModulePorts();
|
||||||
|
board_trainer_init();
|
||||||
|
|
||||||
audioInit();
|
audioInit();
|
||||||
keysInit();
|
keysInit();
|
||||||
switchInit();
|
switchInit();
|
||||||
@@ -206,7 +200,6 @@ void boardInit()
|
|||||||
initCSD203();
|
initCSD203();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
usbInit();
|
|
||||||
hapticInit();
|
hapticInit();
|
||||||
|
|
||||||
#if defined(LED_STRIP_GPIO)
|
#if defined(LED_STRIP_GPIO)
|
||||||
|
|||||||
@@ -132,19 +132,6 @@ enum {
|
|||||||
#define EXTERNAL_MODULE_ON() gpio_set(EXTMODULE_PWR_GPIO)
|
#define EXTERNAL_MODULE_ON() gpio_set(EXTMODULE_PWR_GPIO)
|
||||||
#define EXTERNAL_MODULE_OFF() gpio_clear(EXTMODULE_PWR_GPIO)
|
#define EXTERNAL_MODULE_OFF() gpio_clear(EXTMODULE_PWR_GPIO)
|
||||||
|
|
||||||
#if !defined(PXX2)
|
|
||||||
#define IS_PXX2_INTERNAL_ENABLED() (false)
|
|
||||||
#define IS_PXX1_INTERNAL_ENABLED() (true)
|
|
||||||
#elif !defined(PXX1)
|
|
||||||
#define IS_PXX2_INTERNAL_ENABLED() (true)
|
|
||||||
#define IS_PXX1_INTERNAL_ENABLED() (false)
|
|
||||||
#else
|
|
||||||
// TODO #define PXX2_PROBE
|
|
||||||
// TODO #define IS_PXX2_INTERNAL_ENABLED() (hardwareOptions.pxx2Enabled)
|
|
||||||
#define IS_PXX2_INTERNAL_ENABLED() (true)
|
|
||||||
#define IS_PXX1_INTERNAL_ENABLED() (true)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// POTS and SLIDERS default configuration
|
// POTS and SLIDERS default configuration
|
||||||
#if defined(RADIO_TX16S) || defined(RADIO_F16) || defined(RADIO_V16)
|
#if defined(RADIO_TX16S) || defined(RADIO_F16) || defined(RADIO_V16)
|
||||||
#define XPOS_CALIB_DEFAULT {0x3, 0xc, 0x15, 0x1e, 0x26}
|
#define XPOS_CALIB_DEFAULT {0x3, 0xc, 0x15, 0x1e, 0x26}
|
||||||
|
|||||||
@@ -110,13 +110,14 @@ void boardInit()
|
|||||||
{
|
{
|
||||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
|
||||||
|
|
||||||
#if defined(USB_CHARGE_LED) && !defined(DEBUG)
|
delaysInit();
|
||||||
usbInit();
|
timersInit();
|
||||||
// prime debounce state...
|
__enable_irq();
|
||||||
usbPlugged();
|
|
||||||
|
|
||||||
|
usbInit();
|
||||||
|
|
||||||
|
#if defined(USB_CHARGE_LED) && !defined(DEBUG)
|
||||||
if (usbPlugged()) {
|
if (usbPlugged()) {
|
||||||
delaysInit();
|
|
||||||
#if defined(AUDIO_MUTE_GPIO)
|
#if defined(AUDIO_MUTE_GPIO)
|
||||||
// Charging can make a buzzing noise
|
// Charging can make a buzzing noise
|
||||||
gpio_init(AUDIO_MUTE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
gpio_init(AUDIO_MUTE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||||
@@ -144,22 +145,6 @@ void boardInit()
|
|||||||
pwrInit();
|
pwrInit();
|
||||||
boardInitModulePorts();
|
boardInitModulePorts();
|
||||||
|
|
||||||
#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);
|
|
||||||
trainerSetChangeCb(_intmodule_heartbeat_trainer_hook);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// #if defined(AUTOUPDATE)
|
|
||||||
// telemetryPortInit(FRSKY_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
|
|
||||||
// sportSendByteLoop(0x7E);
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
#if defined(STATUS_LEDS)
|
#if defined(STATUS_LEDS)
|
||||||
ledInit();
|
ledInit();
|
||||||
#if !defined(POWER_LED_BLUE)
|
#if !defined(POWER_LED_BLUE)
|
||||||
@@ -174,14 +159,7 @@ void boardInit()
|
|||||||
// - function switches and the radio supports charging
|
// - function switches and the radio supports charging
|
||||||
// - single USB for data + charge which powers on radio
|
// - single USB for data + charge which powers on radio
|
||||||
#if defined(MANUFACTURER_JUMPER) && !defined(USB_CHARGE_LED)
|
#if defined(MANUFACTURER_JUMPER) && !defined(USB_CHARGE_LED)
|
||||||
// This is needed to prevent radio from starting when usb is plugged to charge
|
|
||||||
usbInit();
|
|
||||||
// prime debounce state...
|
|
||||||
usbPlugged();
|
|
||||||
|
|
||||||
if (usbPlugged()) {
|
if (usbPlugged()) {
|
||||||
delaysInit();
|
|
||||||
__enable_irq();
|
|
||||||
adcInit(&_adc_driver);
|
adcInit(&_adc_driver);
|
||||||
getADC();
|
getADC();
|
||||||
pwrOn(); // required to get bat adc reads
|
pwrOn(); // required to get bat adc reads
|
||||||
@@ -212,10 +190,6 @@ void boardInit()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delaysInit();
|
|
||||||
timersInit();
|
|
||||||
__enable_irq();
|
|
||||||
|
|
||||||
keysInit();
|
keysInit();
|
||||||
switchInit();
|
switchInit();
|
||||||
|
|
||||||
@@ -230,7 +204,6 @@ void boardInit()
|
|||||||
|
|
||||||
lcdInit(); // delaysInit() must be called before
|
lcdInit(); // delaysInit() must be called before
|
||||||
audioInit();
|
audioInit();
|
||||||
usbInit();
|
|
||||||
|
|
||||||
#if defined(LED_STRIP_GPIO)
|
#if defined(LED_STRIP_GPIO)
|
||||||
rgbLedInit();
|
rgbLedInit();
|
||||||
@@ -240,10 +213,6 @@ void boardInit()
|
|||||||
hapticInit();
|
hapticInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PXX2_PROBE)
|
|
||||||
intmodulePxx2Probe();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
// Freeze timers & watchdog when core is halted
|
// Freeze timers & watchdog when core is halted
|
||||||
DBGMCU->APB1FZ = 0x00E009FF;
|
DBGMCU->APB1FZ = 0x00E009FF;
|
||||||
@@ -277,7 +246,6 @@ void boardInit()
|
|||||||
#if defined(RADIO_GX12)
|
#if defined(RADIO_GX12)
|
||||||
gpio_init(HALL_SYNC, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
gpio_init(HALL_SYNC, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user