From 819479cfd9a99e4407d3df9009dd434a2a4e259d Mon Sep 17 00:00:00 2001 From: 3djc Date: Sat, 13 Sep 2025 23:38:11 +0200 Subject: [PATCH] chore: reorg TX15 files (#6560) --- .../tx15 => boards/rm-h750}/audio_driver.cpp | 2 +- .../rm-h750}/backlight_driver.cpp | 13 -------- .../tx15 => boards/rm-h750}/board.cpp | 3 ++ .../{targets/tx15 => boards/rm-h750}/board.h | 4 --- .../tx15 => boards/rm-h750}/bsp_io.cpp | 25 ++++++++------- .../rm-h750}/extflash_driver.cpp | 0 .../tx15 => boards/rm-h750}/extflash_driver.h | 0 .../tx15 => boards/rm-h750}/haptic_driver.cpp | 0 .../rm-h750/lcd_driver_480.cpp} | 2 +- .../rm-h750/lcd_driver_480.h} | 4 --- .../tx15 => boards/rm-h750}/led_driver.cpp | 0 .../tx15 => boards/rm-h750}/sdram_driver.cpp | 0 .../tx15 => boards/rm-h750}/system_clock.c | 0 .../tx15 => boards/rm-h750}/system_clock.h | 0 .../tx15 => boards/rm-h750}/touch_driver.h | 0 .../tx15 => boards/rm-h750}/tp_gt911.cpp | 0 .../tx15 => boards/rm-h750}/tp_gt911.h | 0 .../rm-h750}/usb_charger_driver.cpp | 0 radio/src/targets/tx15/CMakeLists.txt | 31 ++++++++++--------- radio/src/targets/tx15/bsp_io.h | 24 +++----------- radio/src/targets/tx15/hal.h | 1 + radio/src/targets/tx15/usb_descriptor.h | 2 +- 22 files changed, 42 insertions(+), 69 deletions(-) rename radio/src/{targets/tx15 => boards/rm-h750}/audio_driver.cpp (98%) rename radio/src/{targets/tx15 => boards/rm-h750}/backlight_driver.cpp (86%) rename radio/src/{targets/tx15 => boards/rm-h750}/board.cpp (99%) rename radio/src/{targets/tx15 => boards/rm-h750}/board.h (96%) rename radio/src/{targets/tx15 => boards/rm-h750}/bsp_io.cpp (90%) rename radio/src/{targets/tx15 => boards/rm-h750}/extflash_driver.cpp (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/extflash_driver.h (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/haptic_driver.cpp (100%) rename radio/src/{targets/tx15/lcd_driver.cpp => boards/rm-h750/lcd_driver_480.cpp} (99%) rename radio/src/{targets/tx15/lcd_driver.h => boards/rm-h750/lcd_driver_480.h} (95%) rename radio/src/{targets/tx15 => boards/rm-h750}/led_driver.cpp (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/sdram_driver.cpp (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/system_clock.c (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/system_clock.h (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/touch_driver.h (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/tp_gt911.cpp (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/tp_gt911.h (100%) rename radio/src/{targets/tx15 => boards/rm-h750}/usb_charger_driver.cpp (100%) diff --git a/radio/src/targets/tx15/audio_driver.cpp b/radio/src/boards/rm-h750/audio_driver.cpp similarity index 98% rename from radio/src/targets/tx15/audio_driver.cpp rename to radio/src/boards/rm-h750/audio_driver.cpp index 9be1fa133..77c636a98 100644 --- a/radio/src/targets/tx15/audio_driver.cpp +++ b/radio/src/boards/rm-h750/audio_driver.cpp @@ -73,7 +73,7 @@ int audioInit() memset(_dma_buffer, 0, sizeof(_dma_buffer)); - if (tas2505_probe(&_tas2505, 0, 0x30 >> 1) < 0) { + if (tas2505_probe(&_tas2505, AUDIO_I2C, 0x30 >> 1) < 0) { return -1; } diff --git a/radio/src/targets/tx15/backlight_driver.cpp b/radio/src/boards/rm-h750/backlight_driver.cpp similarity index 86% rename from radio/src/targets/tx15/backlight_driver.cpp rename to radio/src/boards/rm-h750/backlight_driver.cpp index 1d0c5a40d..5452b87a3 100644 --- a/radio/src/targets/tx15/backlight_driver.cpp +++ b/radio/src/boards/rm-h750/backlight_driver.cpp @@ -28,7 +28,6 @@ #include "board.h" #include "globals.h" -#include "lcd_driver.h" static const stm32_pulse_timer_t _bl_timer = { .GPIO = (gpio_t)BACKLIGHT_GPIO, @@ -63,16 +62,6 @@ uint8_t lastDutyCycle = 0; void backlightEnable(uint8_t dutyCycle) { stm32_pulse_set_cmp_val(&_bl_timer, dutyCycle); - - if(!dutyCycle) { - //experimental to turn off LCD when no backlight - if(lcdOffFunction) lcdOffFunction(); - } - else if(!lastDutyCycle) { - if(lcdOnFunction) lcdOnFunction(); - else lcdInit(); - } - lastDutyCycle = dutyCycle; } @@ -81,8 +70,6 @@ void lcdOff() { } void lcdOn(){ - // if(lcdOnFunction) lcdOnFunction(); - // else lcdInit(); backlightEnable(BACKLIGHT_LEVEL_MAX); } diff --git a/radio/src/targets/tx15/board.cpp b/radio/src/boards/rm-h750/board.cpp similarity index 99% rename from radio/src/targets/tx15/board.cpp rename to radio/src/boards/rm-h750/board.cpp index 93d1e57c4..a6b3e0112 100644 --- a/radio/src/targets/tx15/board.cpp +++ b/radio/src/boards/rm-h750/board.cpp @@ -153,11 +153,14 @@ void boardInit() flashRegisterDriver(QSPI_BASE, QSPI_FLASH_SIZE, &extflash_driver); // init_trainer(); + +#if defined(FLYSKY_GIMBAL) auto inittime = flysky_gimbal_init(); if (inittime) TRACE("Serial gimbal detected in %d ms", inittime); else TRACE("No serial gimbal detected"); +#endif usbInit(); diff --git a/radio/src/targets/tx15/board.h b/radio/src/boards/rm-h750/board.h similarity index 96% rename from radio/src/targets/tx15/board.h rename to radio/src/boards/rm-h750/board.h index c11728f41..3bae5a600 100644 --- a/radio/src/targets/tx15/board.h +++ b/radio/src/boards/rm-h750/board.h @@ -200,10 +200,6 @@ bool isBacklightEnabled(); : g_eeGeneral.blOffBright); \ } -#define USB_NAME "TX15" -#define USB_MANUFACTURER 'R', 'M', ' ', ' ', ' ', ' ', ' ', ' ' /* 8 bytes */ -#define USB_PRODUCT 'T', 'X', '1', '5', ' ', ' ', ' ', ' ' /* 8 Bytes */ - #if defined(__cplusplus) && !defined(SIMU) } #endif diff --git a/radio/src/targets/tx15/bsp_io.cpp b/radio/src/boards/rm-h750/bsp_io.cpp similarity index 90% rename from radio/src/targets/tx15/bsp_io.cpp rename to radio/src/boards/rm-h750/bsp_io.cpp index 94ca1be71..763b4ad6f 100644 --- a/radio/src/targets/tx15/bsp_io.cpp +++ b/radio/src/boards/rm-h750/bsp_io.cpp @@ -60,19 +60,18 @@ static void _init_io_expander(bsp_io_expander* io, uint32_t mask) io->state = 0; } -static volatile uint8_t pca95xx_errors = 0; - static uint32_t _read_io_expander(bsp_io_expander* io) { uint16_t value = 0; if (pca95xx_read(&io->exp, io->mask, &value) == 0) { io->state = value; } else { - if (pca95xx_errors++ > 5) { - gpio_clear(IO_RESET_GPIO); - pca95xx_errors = 0; - delay_us(1); // Only 6ns are needed according to PCA datasheet, but lets be safe - gpio_set(IO_RESET_GPIO); + gpio_clear(IO_RESET_GPIO); + delay_us(1); // Only 4ns are needed according to PCA datasheet + gpio_set(IO_RESET_GPIO); + // Re read + if (pca95xx_read(&io->exp, io->mask, &value) == 0) { + io->state = value; } } @@ -129,14 +128,14 @@ int bsp_io_init() gpio_set(IO_RESET_GPIO); // configure expander 1 - _init_io_expander(&_io_fs_switches, 0xFF3F); + _init_io_expander(&_io_fs_switches, EXP_1_MASK); if (pca95xx_init(&_io_fs_switches.exp, I2C_Bus_1, 0x74) < 0) { TRACE("EXP1 INIT ERROR"); return -1; } // configure expander 2 - _init_io_expander(&_io_switches, 0xFFF8); + _init_io_expander(&_io_switches, EXP_2_MASK); if (pca95xx_init(&_io_switches.exp, I2C_Bus_1, 0x75) < 0) { TRACE("EXP2 INIT ERROR"); return -1; @@ -211,9 +210,13 @@ static SwitchHwPos _get_fs_switch_pos(uint8_t idx) } } +bool boardIsCustomSwitch(uint8_t idx); + SwitchHwPos boardSwitchGetPosition(uint8_t idx) { - if (idx < 6) + if (boardIsCustomSwitch(idx)) { + return _get_fs_switch_pos(idx); + } else { return _get_switch_pos(idx); - return _get_fs_switch_pos(idx); + } } diff --git a/radio/src/targets/tx15/extflash_driver.cpp b/radio/src/boards/rm-h750/extflash_driver.cpp similarity index 100% rename from radio/src/targets/tx15/extflash_driver.cpp rename to radio/src/boards/rm-h750/extflash_driver.cpp diff --git a/radio/src/targets/tx15/extflash_driver.h b/radio/src/boards/rm-h750/extflash_driver.h similarity index 100% rename from radio/src/targets/tx15/extflash_driver.h rename to radio/src/boards/rm-h750/extflash_driver.h diff --git a/radio/src/targets/tx15/haptic_driver.cpp b/radio/src/boards/rm-h750/haptic_driver.cpp similarity index 100% rename from radio/src/targets/tx15/haptic_driver.cpp rename to radio/src/boards/rm-h750/haptic_driver.cpp diff --git a/radio/src/targets/tx15/lcd_driver.cpp b/radio/src/boards/rm-h750/lcd_driver_480.cpp similarity index 99% rename from radio/src/targets/tx15/lcd_driver.cpp rename to radio/src/boards/rm-h750/lcd_driver_480.cpp index accfdcdbf..c8b761289 100644 --- a/radio/src/targets/tx15/lcd_driver.cpp +++ b/radio/src/boards/rm-h750/lcd_driver_480.cpp @@ -27,7 +27,7 @@ #include "delays_driver.h" #include "debug.h" #include "lcd.h" -#include "lcd_driver.h" +#include "lcd_driver_480.h" #include "board.h" #include "hal/gpio.h" diff --git a/radio/src/targets/tx15/lcd_driver.h b/radio/src/boards/rm-h750/lcd_driver_480.h similarity index 95% rename from radio/src/targets/tx15/lcd_driver.h rename to radio/src/boards/rm-h750/lcd_driver_480.h index 19c8b3362..dbb2e52d1 100644 --- a/radio/src/targets/tx15/lcd_driver.h +++ b/radio/src/boards/rm-h750/lcd_driver_480.h @@ -38,10 +38,6 @@ typedef void (*lcdSpiInitFucPtr)(void); typedef unsigned int LcdReadIDFucPtr( void ); -extern lcdSpiInitFucPtr lcdInitFunction; -extern lcdSpiInitFucPtr lcdOffFunction; -extern lcdSpiInitFucPtr lcdOnFunction; - #define SET_IO_INPUT( PORT, PIN ) LL_GPIO_SetPinMode( PORT, PIN, LL_GPIO_MODE_INPUT ) #define SET_IO_OUTPUT( PORT, PIN ) LL_GPIO_SetPinMode( PORT, PIN, LL_GPIO_MODE_OUTPUT ) diff --git a/radio/src/targets/tx15/led_driver.cpp b/radio/src/boards/rm-h750/led_driver.cpp similarity index 100% rename from radio/src/targets/tx15/led_driver.cpp rename to radio/src/boards/rm-h750/led_driver.cpp diff --git a/radio/src/targets/tx15/sdram_driver.cpp b/radio/src/boards/rm-h750/sdram_driver.cpp similarity index 100% rename from radio/src/targets/tx15/sdram_driver.cpp rename to radio/src/boards/rm-h750/sdram_driver.cpp diff --git a/radio/src/targets/tx15/system_clock.c b/radio/src/boards/rm-h750/system_clock.c similarity index 100% rename from radio/src/targets/tx15/system_clock.c rename to radio/src/boards/rm-h750/system_clock.c diff --git a/radio/src/targets/tx15/system_clock.h b/radio/src/boards/rm-h750/system_clock.h similarity index 100% rename from radio/src/targets/tx15/system_clock.h rename to radio/src/boards/rm-h750/system_clock.h diff --git a/radio/src/targets/tx15/touch_driver.h b/radio/src/boards/rm-h750/touch_driver.h similarity index 100% rename from radio/src/targets/tx15/touch_driver.h rename to radio/src/boards/rm-h750/touch_driver.h diff --git a/radio/src/targets/tx15/tp_gt911.cpp b/radio/src/boards/rm-h750/tp_gt911.cpp similarity index 100% rename from radio/src/targets/tx15/tp_gt911.cpp rename to radio/src/boards/rm-h750/tp_gt911.cpp diff --git a/radio/src/targets/tx15/tp_gt911.h b/radio/src/boards/rm-h750/tp_gt911.h similarity index 100% rename from radio/src/targets/tx15/tp_gt911.h rename to radio/src/boards/rm-h750/tp_gt911.h diff --git a/radio/src/targets/tx15/usb_charger_driver.cpp b/radio/src/boards/rm-h750/usb_charger_driver.cpp similarity index 100% rename from radio/src/targets/tx15/usb_charger_driver.cpp rename to radio/src/boards/rm-h750/usb_charger_driver.cpp diff --git a/radio/src/targets/tx15/CMakeLists.txt b/radio/src/targets/tx15/CMakeLists.txt index 733e4e699..a5cde3357 100644 --- a/radio/src/targets/tx15/CMakeLists.txt +++ b/radio/src/targets/tx15/CMakeLists.txt @@ -63,7 +63,6 @@ set(HARDWARE_TOUCH YES) set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} ${BITMAPS_TARGET}) set(FIRMWARE_DEPENDENCIES datacopy) set(SOFTWARE_KEYBOARD ON) -set(FLYSKY_GIMBAL ON) set(FUNCTION_SWITCHES ON) set(USB_CHARGER YES) set(AUX_SERIAL YES) @@ -112,17 +111,22 @@ set(AFHDS3 ON) set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough") set(CLI ON CACHE BOOL "Enable CLI") +set(BOARD rm-h750) + +include_directories(boards/${BOARD}) + set(TARGET_SRC_DIR targets/${TARGET_DIR}) +set(BOARD_SRC_DIR boards/${BOARD}) set(BOARD_COMMON_SRC - ${TARGET_SRC_DIR}/board.cpp - ${TARGET_SRC_DIR}/bsp_io.cpp + ${BOARD_SRC_DIR}/board.cpp + ${BOARD_SRC_DIR}/bsp_io.cpp + ${BOARD_SRC_DIR}/lcd_driver_480.cpp + ${BOARD_SRC_DIR}/backlight_driver.cpp + ${BOARD_SRC_DIR}/haptic_driver.cpp + ${BOARD_SRC_DIR}/extflash_driver.cpp + ${BOARD_SRC_DIR}/usb_charger_driver.cpp ${TARGET_SRC_DIR}/key_driver.cpp - ${TARGET_SRC_DIR}/lcd_driver.cpp - ${TARGET_SRC_DIR}/backlight_driver.cpp - ${TARGET_SRC_DIR}/haptic_driver.cpp - ${TARGET_SRC_DIR}/extflash_driver.cpp - ${TARGET_SRC_DIR}/usb_charger_driver.cpp targets/common/arm/stm32/abnormal_reboot.cpp targets/common/arm/stm32/delays_driver.cpp targets/common/arm/stm32/dma2d.cpp @@ -137,8 +141,7 @@ set(BOARD_COMMON_SRC # Bootloader board library add_library(board_bl OBJECT EXCLUDE_FROM_ALL ${BOARD_COMMON_SRC} - ${TARGET_SRC_DIR}/sdram_driver.cpp - ${TARGET_SRC_DIR}/usb_charger_driver.cpp + ${BOARD_SRC_DIR}/sdram_driver.cpp ${RADIO_SRC_DIR}/gui/colorlcd/boot_menu.cpp targets/common/arm/stm32/stm32_qspi.cpp targets/common/arm/stm32/stm32_pulse_driver.cpp @@ -146,14 +149,14 @@ add_library(board_bl OBJECT EXCLUDE_FROM_ALL add_dependencies(board_bl minimal_board_lib) set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $) -set(CMSIS_SRC ${TARGET_SRC_DIR}/system_clock.c) +set(CMSIS_SRC ${BOARD_SRC_DIR}/system_clock.c) # Firmware board library add_library(board OBJECT EXCLUDE_FROM_ALL ${BOARD_COMMON_SRC} - ${TARGET_SRC_DIR}/led_driver.cpp - ${TARGET_SRC_DIR}/tp_gt911.cpp - ${TARGET_SRC_DIR}/audio_driver.cpp + ${BOARD_SRC_DIR}/led_driver.cpp + ${BOARD_SRC_DIR}/tp_gt911.cpp + ${BOARD_SRC_DIR}/audio_driver.cpp drivers/icm42607C.cpp drivers/imu_filter.cpp drivers/tas2505.cpp diff --git a/radio/src/targets/tx15/bsp_io.h b/radio/src/targets/tx15/bsp_io.h index dafcc45ba..3ff8305db 100644 --- a/radio/src/targets/tx15/bsp_io.h +++ b/radio/src/targets/tx15/bsp_io.h @@ -24,19 +24,6 @@ #include "drivers/pca95xx.h" #include "hal/switch_driver.h" -// Port expander 1 (0x74) -#define SWITCH_A_L PCA95XX_P14 -#define SWITCH_A_H PCA95XX_P15 -#define SWITCH_B_L PCA95XX_P12 -#define SWITCH_B_H PCA95XX_P13 -#define SWITCH_C_L PCA95XX_P10 -#define SWITCH_C_H PCA95XX_P11 -#define SWITCH_D_L PCA95XX_P6 -#define SWITCH_D_H PCA95XX_P7 -#define SWITCH_E_L PCA95XX_P16 -#define SWITCH_E_H PCA95XX_P17 -#define SWITCH_F_H PCA95XX_P4 -#define SWITCH_F_L PCA95XX_P5 // Port expander 2 (0x75) #define BSP_TR1U PCA95XX_PIN_13 @@ -51,13 +38,6 @@ #define BSP_TR4L PCA95XX_PIN_9 #define BSP_TR4R PCA95XX_PIN_8 -#define FSSWITCH_1 PCA95XX_P0 -#define FSSWITCH_2 PCA95XX_P1 -#define FSSWITCH_3 PCA95XX_P2 -#define FSSWITCH_4 PCA95XX_P3 -#define FSSWITCH_5 PCA95XX_P4 -#define FSSWITCH_6 PCA95XX_P5 - extern uint8_t isSwitch3Pos(uint8_t idx); int bsp_io_init(); @@ -67,3 +47,7 @@ uint32_t bsp_get_fs_switches(); uint16_t bsp_input_get(); struct stm32_switch_t; + +//TODO compute from json +constexpr uint32_t EXP_1_MASK = 0xFF3F; +constexpr uint32_t EXP_2_MASK = 0xFFF8; diff --git a/radio/src/targets/tx15/hal.h b/radio/src/targets/tx15/hal.h index 3450d2034..f6650bce5 100644 --- a/radio/src/targets/tx15/hal.h +++ b/radio/src/targets/tx15/hal.h @@ -354,6 +354,7 @@ TIM17: ROTARY_ENCODER_TIMER // AUDIO +#define AUDIO_I2C I2C_Bus_1 #define AUDIO_SPI SPI2 #define AUDIO_RESET_PIN GPIO_PIN(GPIOH, 10) #define AUDIO_HP_DETECT_PIN GPIO_PIN(GPIOA, 5) diff --git a/radio/src/targets/tx15/usb_descriptor.h b/radio/src/targets/tx15/usb_descriptor.h index 1edca8594..c87bc1e75 100644 --- a/radio/src/targets/tx15/usb_descriptor.h +++ b/radio/src/targets/tx15/usb_descriptor.h @@ -22,7 +22,7 @@ #ifndef _USB_DESCRIPTOR_H_ #define _USB_DESCRIPTOR_H_ -#define USB_NAME "TX15" +#define USB_NAME "RadioMaster TX15" #define USB_MANUFACTURER 'R', 'M', ' ', ' ', ' ', ' ', ' ', ' ' /* 8 bytes */ #define USB_PRODUCT 'T', 'X', '1', '5', ' ', ' ', ' ', ' ' /* 8 Bytes */