refactor(boot): move BT and rotary encoder init to board specifics (#7265)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
ac4c4d7b6b
commit
559866c059
@@ -100,6 +100,10 @@ void boardBLPreJump()
|
|||||||
|
|
||||||
void boardBLInit()
|
void boardBLInit()
|
||||||
{
|
{
|
||||||
|
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
|
rotaryEncoderInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
ExtFLASH_Init();
|
ExtFLASH_Init();
|
||||||
SDRAM_Init();
|
SDRAM_Init();
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,10 @@ void boardBLPreJump()
|
|||||||
|
|
||||||
void boardBLInit()
|
void boardBLInit()
|
||||||
{
|
{
|
||||||
|
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
|
rotaryEncoderInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
ExtFLASH_Init();
|
ExtFLASH_Init();
|
||||||
SDRAM_Init();
|
SDRAM_Init();
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,12 @@
|
|||||||
|
|
||||||
#include "hal/usb_driver.h"
|
#include "hal/usb_driver.h"
|
||||||
#include "hal/abnormal_reboot.h"
|
#include "hal/abnormal_reboot.h"
|
||||||
#include "hal/rotary_encoder.h"
|
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "timers_driver.h"
|
#include "timers_driver.h"
|
||||||
|
|
||||||
#if defined(BLUETOOTH)
|
|
||||||
#include "bluetooth_driver.h"
|
|
||||||
#include "stm32_serial_driver.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(DEBUG_SEGGER_RTT)
|
#if defined(DEBUG_SEGGER_RTT)
|
||||||
#include "thirdparty/Segger/SEGGER/SEGGER_RTT.h"
|
#include "thirdparty/Segger/SEGGER/SEGGER_RTT.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -107,26 +101,12 @@ void bootloaderInitApp()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move all this into board specifics
|
|
||||||
pwrOn();
|
pwrOn();
|
||||||
|
|
||||||
#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS)
|
|
||||||
rotaryEncoderInit();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
|
|
||||||
TRACE("\nBootloader started :)");
|
TRACE("\nBootloader started :)");
|
||||||
|
|
||||||
// TODO: move BT into board specifics
|
|
||||||
#if defined(BLUETOOTH)
|
|
||||||
// we shutdown the bluetooth module now to be sure it will be detected on
|
|
||||||
// firmware start
|
|
||||||
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
timersInit();
|
timersInit();
|
||||||
|
|
||||||
usbInit();
|
usbInit();
|
||||||
boardBLInit();
|
boardBLInit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,11 @@
|
|||||||
|
|
||||||
#include "stm32_hal_ll.h"
|
#include "stm32_hal_ll.h"
|
||||||
#include "stm32_gpio.h"
|
#include "stm32_gpio.h"
|
||||||
|
#include "stm32_serial_driver.h"
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if !defined(BOOT)
|
|
||||||
|
|
||||||
#include "stm32_serial_driver.h"
|
|
||||||
|
|
||||||
#define BT_USART_IRQ_PRIORITY 6
|
#define BT_USART_IRQ_PRIORITY 6
|
||||||
|
|
||||||
static const stm32_usart_t btUSART = {
|
static const stm32_usart_t btUSART = {
|
||||||
@@ -54,9 +51,7 @@ DEFINE_STM32_SERIAL_PORT(BTModule, btUSART, BT_RX_FIFO_SIZE, BT_TX_FIFO_SIZE);
|
|||||||
volatile uint8_t btChipPresent = 0;
|
volatile uint8_t btChipPresent = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// const etx_serial_driver_t* _bt_usart_drv = nullptr;
|
|
||||||
void* _bt_usart_ctx = nullptr;
|
void* _bt_usart_ctx = nullptr;
|
||||||
#endif
|
|
||||||
|
|
||||||
void bluetoothInit(uint32_t baudrate, bool enable)
|
void bluetoothInit(uint32_t baudrate, bool enable)
|
||||||
{
|
{
|
||||||
@@ -67,7 +62,6 @@ void bluetoothInit(uint32_t baudrate, bool enable)
|
|||||||
gpio_init(BT_PWR_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
gpio_init(BT_PWR_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOT)
|
|
||||||
etx_serial_init cfg = {
|
etx_serial_init cfg = {
|
||||||
.baudrate = baudrate,
|
.baudrate = baudrate,
|
||||||
.encoding = ETX_Encoding_8N1,
|
.encoding = ETX_Encoding_8N1,
|
||||||
@@ -81,7 +75,6 @@ void bluetoothInit(uint32_t baudrate, bool enable)
|
|||||||
} else {
|
} else {
|
||||||
STM32SerialDriver.setBaudrate(_bt_usart_ctx, baudrate);
|
STM32SerialDriver.setBaudrate(_bt_usart_ctx, baudrate);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BT_EN_GPIO)
|
#if defined(BT_EN_GPIO)
|
||||||
gpio_write(BT_EN_GPIO, !enable);
|
gpio_write(BT_EN_GPIO, !enable);
|
||||||
@@ -91,7 +84,6 @@ void bluetoothInit(uint32_t baudrate, bool enable)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOT)
|
|
||||||
void bluetoothDisable()
|
void bluetoothDisable()
|
||||||
{
|
{
|
||||||
#if defined(BT_EN_GPIO)
|
#if defined(BT_EN_GPIO)
|
||||||
@@ -123,7 +115,6 @@ uint8_t bluetoothIsWriting(void)
|
|||||||
{
|
{
|
||||||
if (!_bt_usart_ctx)
|
if (!_bt_usart_ctx)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !STM32SerialDriver.txCompleted(_bt_usart_ctx);
|
return !STM32SerialDriver.txCompleted(_bt_usart_ctx);
|
||||||
}
|
}
|
||||||
#endif // !BOOT
|
|
||||||
|
|||||||
@@ -264,12 +264,6 @@ else()
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BLUETOOTH)
|
|
||||||
set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC}
|
|
||||||
targets/common/arm/stm32/bluetooth_driver.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (VIDEO_SWITCH)
|
if (VIDEO_SWITCH)
|
||||||
add_definitions(-DVIDEO_SWITCH)
|
add_definitions(-DVIDEO_SWITCH)
|
||||||
set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC}
|
set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC}
|
||||||
@@ -303,6 +297,10 @@ add_library(board OBJECT EXCLUDE_FROM_ALL
|
|||||||
)
|
)
|
||||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:board>)
|
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:board>)
|
||||||
|
|
||||||
|
if(BLUETOOTH)
|
||||||
|
target_sources(board PRIVATE targets/common/arm/stm32/bluetooth_driver.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(HARDWARE_TOUCH)
|
if(HARDWARE_TOUCH)
|
||||||
add_definitions(-DHARDWARE_TOUCH)
|
add_definitions(-DHARDWARE_TOUCH)
|
||||||
|
|
||||||
|
|||||||
@@ -59,12 +59,29 @@
|
|||||||
HardwareOptions hardwareOptions;
|
HardwareOptions hardwareOptions;
|
||||||
bool boardBacklightOn = false;
|
bool boardBacklightOn = false;
|
||||||
|
|
||||||
|
#if defined(VIDEO_SWITCH) || (defined(BLUETOOTH) && defined(BOOT))
|
||||||
|
|
||||||
#if defined(VIDEO_SWITCH)
|
#if defined(VIDEO_SWITCH)
|
||||||
#include "videoswitch_driver.h"
|
#include "videoswitch_driver.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void boardBLEarlyInit()
|
void boardBLEarlyInit()
|
||||||
{
|
{
|
||||||
|
#if defined(VIDEO_SWITCH)
|
||||||
videoSwitchInit();
|
videoSwitchInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BLUETOOTH)
|
||||||
|
// Disable the BT module so it will be detected on firmware start
|
||||||
|
#if defined(BT_EN_GPIO)
|
||||||
|
gpio_init(BT_EN_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||||
|
gpio_write(BT_EN_GPIO, 1);
|
||||||
|
#endif
|
||||||
|
#if defined(BT_PWR_GPIO)
|
||||||
|
gpio_init(BT_PWR_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||||
|
gpio_set(BT_PWR_GPIO);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -77,6 +94,7 @@ void boardBLPreJump()
|
|||||||
|
|
||||||
void boardBLInit()
|
void boardBLInit()
|
||||||
{
|
{
|
||||||
|
rotaryEncoderInit();
|
||||||
SDRAM_Init();
|
SDRAM_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ void boardBLPreJump()
|
|||||||
|
|
||||||
void boardBLInit()
|
void boardBLInit()
|
||||||
{
|
{
|
||||||
|
rotaryEncoderInit();
|
||||||
|
|
||||||
ExtFLASH_Init();
|
ExtFLASH_Init();
|
||||||
SDRAM_Init();
|
SDRAM_Init();
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,9 @@ void boardBLPreJump()
|
|||||||
|
|
||||||
void boardBLInit()
|
void boardBLInit()
|
||||||
{
|
{
|
||||||
|
#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS)
|
||||||
|
rotaryEncoderInit();
|
||||||
|
#endif
|
||||||
SDRAM_Init();
|
SDRAM_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,6 +164,8 @@ void boardBLPreJump()
|
|||||||
|
|
||||||
void boardBLInit()
|
void boardBLInit()
|
||||||
{
|
{
|
||||||
|
rotaryEncoderInit();
|
||||||
|
|
||||||
ExtFLASH_Init();
|
ExtFLASH_Init();
|
||||||
SDRAM_Init();
|
SDRAM_Init();
|
||||||
|
|
||||||
|
|||||||
@@ -581,12 +581,6 @@ if(ROTARY_ENCODER)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BLUETOOTH)
|
|
||||||
list(APPEND BOARD_COMMON_SRC
|
|
||||||
targets/common/arm/stm32/bluetooth_driver.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Bootloader board library
|
# Bootloader board library
|
||||||
add_library(board_bl OBJECT EXCLUDE_FROM_ALL
|
add_library(board_bl OBJECT EXCLUDE_FROM_ALL
|
||||||
${BOARD_COMMON_SRC}
|
${BOARD_COMMON_SRC}
|
||||||
@@ -612,6 +606,10 @@ add_library(board OBJECT EXCLUDE_FROM_ALL
|
|||||||
)
|
)
|
||||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:board>)
|
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:board>)
|
||||||
|
|
||||||
|
if(BLUETOOTH)
|
||||||
|
target_sources(board PRIVATE targets/common/arm/stm32/bluetooth_driver.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(BIND_KEY)
|
if(BIND_KEY)
|
||||||
add_definitions(-DBIND_KEY)
|
add_definitions(-DBIND_KEY)
|
||||||
target_sources(board PRIVATE ${TARGET_SRC_DIR}/bind_button_driver.cpp)
|
target_sources(board PRIVATE ${TARGET_SRC_DIR}/bind_button_driver.cpp)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "hal/switch_driver.h"
|
#include "hal/switch_driver.h"
|
||||||
#include "hal/module_port.h"
|
#include "hal/module_port.h"
|
||||||
#include "hal/abnormal_reboot.h"
|
#include "hal/abnormal_reboot.h"
|
||||||
|
#include "hal/rotary_encoder.h"
|
||||||
#include "hal/usb_driver.h"
|
#include "hal/usb_driver.h"
|
||||||
#include "hal/gpio.h"
|
#include "hal/gpio.h"
|
||||||
#include "hal/rgbleds.h"
|
#include "hal/rgbleds.h"
|
||||||
@@ -48,6 +49,28 @@
|
|||||||
#include "flysky_gimbal_driver.h"
|
#include "flysky_gimbal_driver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOT)
|
||||||
|
|
||||||
|
#if defined(BLUETOOTH)
|
||||||
|
void boardBLEarlyInit()
|
||||||
|
{
|
||||||
|
// Disable the BT module so it will be detected on firmware start
|
||||||
|
#if defined(BT_EN_GPIO)
|
||||||
|
gpio_init(BT_EN_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||||
|
gpio_write(BT_EN_GPIO, 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
|
void boardBLInit()
|
||||||
|
{
|
||||||
|
rotaryEncoderInit();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // BOOT
|
||||||
|
|
||||||
#if !defined(BOOT)
|
#if !defined(BOOT)
|
||||||
#include "edgetx.h"
|
#include "edgetx.h"
|
||||||
#if defined(PXX1)
|
#if defined(PXX1)
|
||||||
|
|||||||
@@ -158,12 +158,6 @@ set(BOARD_COMMON_SRC
|
|||||||
targets/common/arm/stm32/watchdog_driver.cpp
|
targets/common/arm/stm32/watchdog_driver.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BLUETOOTH)
|
|
||||||
set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC}
|
|
||||||
targets/common/arm/stm32/bluetooth_driver.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(KCX_BTAUDIO)
|
if(KCX_BTAUDIO)
|
||||||
set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC}
|
set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC}
|
||||||
drivers/kcx_btaudio.cpp
|
drivers/kcx_btaudio.cpp
|
||||||
@@ -204,6 +198,10 @@ add_library(board OBJECT EXCLUDE_FROM_ALL
|
|||||||
add_dependencies(board board_lib)
|
add_dependencies(board board_lib)
|
||||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:board>)
|
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:board>)
|
||||||
|
|
||||||
|
if(BLUETOOTH)
|
||||||
|
target_sources(board PRIVATE targets/common/arm/stm32/bluetooth_driver.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
include_directories(${RADIO_SRC_DIR}/fonts/colorlcd gui/${GUI_DIR} gui/${GUI_DIR}/layouts)
|
include_directories(${RADIO_SRC_DIR}/fonts/colorlcd gui/${GUI_DIR} gui/${GUI_DIR}/layouts)
|
||||||
|
|
||||||
if(BOOTLOADER)
|
if(BOOTLOADER)
|
||||||
|
|||||||
Reference in New Issue
Block a user