fix: Use keysGetMaxTrims() instead of MAX_TRIMS (#3860)

* fix: use keysGetMaxTrims() instead of MAX_TRIMS

* feat: add support for virtual trims

This is necessary for radios like X-lite where half of the trims are simulated
This commit is contained in:
Raphael Coeffic
2023-07-30 14:18:58 +10:00
committed by GitHub
parent 76423370cd
commit 574369aca4
13 changed files with 55 additions and 36 deletions
@@ -1,6 +1,9 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
AddHardwareDefTarget(${HW_DESC_JSON})
AddHWGenTarget(${HW_DESC_JSON} hal_keys hal_keys.inc)
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
../../../../../gui/${GUI_DIR}/lcd.cpp
@@ -22,11 +25,12 @@ set(BOOTLOADER_SRC
../../../../../${FATFS_DIR}/ffunicode.c
../../../../../targets/${TARGET_DIR}/${LCD_DRIVER}
../../../../../targets/${TARGET_DIR}/backlight_driver.cpp
#../../../../../targets/${TARGET_DIR}/keys_driver.cpp
../../../../../targets/${TARGET_DIR}/diskio.cpp
../../../../../targets/${TARGET_DIR}/board.cpp
../pwr_driver.cpp
../../../../../targets/${TARGET_DIR}/bootloader/boot_menu.cpp
${CMAKE_CURRENT_BINARY_DIR}/hal_keys.inc
../../../../../hal/key_driver.cpp
../pwr_driver.cpp
../usbd_usr.cpp
../usbd_storage_msd.cpp
../delays_driver.cpp
@@ -135,6 +139,10 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs")
add_executable(bootloader EXCLUDE_FROM_ALL ${BOOTLOADER_SRC})
add_dependencies(bootloader ${BITMAPS_TARGET})
target_include_directories(bootloader
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_command(
TARGET bootloader POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O binary bootloader.elf ${CMAKE_BINARY_DIR}/bootloader.bin
+1 -1
View File
@@ -479,7 +479,7 @@ uint32_t readTrims()
{
uint32_t result = 0;
for (int i = 0; i < MAX_TRIMS * 2; i++) {
for (int i = 0; i < keysGetMaxTrims() * 2; i++) {
if (trimsStates[i]) {
// TRACE("trim pressed %d", i);
result |= 1 << i;
+2
View File
@@ -331,6 +331,8 @@
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_0 // PB.00
#define TRIMS_GPIO_REG_LVD GPIOB
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_1 // PB.01
#define TRIMS_VIRTUAL_RV
#define TRIMS_VIRTUAL_RH
#elif defined(RADIO_X7ACCESS)
#define TRIMS_GPIO_REG_LHR GPIOD
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_15 // PD.15