feat: Flysky PL18 Support (#4105)

Co-authored-by: raphaelcoeffic <raphael.coeffic@frafos.com>
Co-authored-by: rotorman <risto.koiva@web.de>
Co-authored-by: Xy201207 <yaoxu@flysky.com>
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
richardclli
2023-12-06 09:00:44 +10:00
committed by GitHub
co-authored by raphaelcoeffic rotorman Xy201207 Peter Feerick
parent 5153aaeea0
commit cc17046e7a
128 changed files with 9178 additions and 171 deletions
@@ -69,8 +69,7 @@ if(DEBUG_SEGGER_RTT)
)
endif()
if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14 OR PCB STREQUAL PL18)
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
../../../../../gui/colorlcd/fonts.cpp
@@ -79,7 +78,6 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
../../../../../thirdparty/libopenui/src/bitmapbuffer.cpp
../../../../../thirdparty/libopenui/thirdparty/lz4/lz4.c
../../../../../targets/common/arm/stm32/dma2d.cpp
../../../../../targets/common/arm/stm32/diskio_sdio.cpp
../../../../../targets/common/arm/stm32/rtc_driver.cpp
../../../../../targets/common/arm/stm32/diskio_spi_flash.cpp
../../../../../targets/common/arm/stm32/spi_flash.cpp
@@ -90,12 +88,22 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
../../../../../targets/${TARGET_DIR}/haptic_driver.cpp
)
if(NOT PCB STREQUAL PL18)
set(BOOTLOADER_SRC ${BOOTLOADER_SRC}
../../../../../targets/common/arm/stm32/diskio_sdio.cpp
)
else()
set(BOOTLOADER_SRC ${BOOTLOADER_SRC}
../../../../../targets/pl18/key_driver.cpp
)
endif()
# Add LVGL sources
foreach(LVGL_FILE ${LVGL_SRC_FILES_MINIMAL})
set(BOOTLOADER_SRC ${BOOTLOADER_SRC} ../../../../../${LVGL_FILE})
endforeach()
if(NOT PCB STREQUAL NV14)
if(NOT (PCB STREQUAL NV14 OR PCB STREQUAL PL18))
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
../../../../../targets/${TARGET_DIR}/led_driver.cpp
@@ -56,12 +56,17 @@
#define APP_START_ADDRESS (uint32_t)(FIRMWARE_ADDRESS + BOOTLOADER_SIZE)
#if defined(EEPROM)
#if defined(EEPROM) || defined(SPI_FLASH)
#define MAIN_MENU_LEN 3
#else
#define MAIN_MENU_LEN 2
#endif
#if defined(SPI_FLASH)
#include "spi_flash.h"
#define SEL_CLEAR_FLASH_STORAGE_MENU_LEN 2
#endif
typedef void (*voidFunction)(void);
#define jumpTo(addr) do { \
@@ -369,6 +374,10 @@ int bootloaderMain()
memoryType = MEM_EEPROM;
state = ST_DIR_CHECK;
break;
#elif defined(SPI_FLASH)
case 1:
state = ST_CLEAR_FLASH_CHECK;
break;
#endif
default:
if(vpos < bootloaderGetMenuItemCount(MAIN_MENU_LEN-1))
@@ -511,6 +520,35 @@ int bootloaderMain()
else if (memoryType == MEM_EEPROM && eepromWritten >= EEPROM_SIZE) {
state = ST_FLASH_DONE; // Backstop
}
#endif
#if defined(SPI_FLASH)
} else if (state == ST_CLEAR_FLASH_CHECK) {
bootloaderDrawScreen(state, vpos);
if (event == EVT_KEY_REPT(KEY_DOWN) || event == EVT_KEY_FIRST(KEY_DOWN)) {
if (vpos < SEL_CLEAR_FLASH_STORAGE_MENU_LEN - 1) { vpos++; }
continue;
}
if (event == EVT_KEY_REPT(KEY_UP) || event == EVT_KEY_FIRST(KEY_UP)) {
if (vpos > 0) { vpos--; }
continue;
}
if (event == EVT_KEY_LONG(KEY_ENTER) && vpos == 0)
{
state = ST_CLEAR_FLASH;
} else if (event == EVT_KEY_BREAK(KEY_EXIT) ||
(event == EVT_KEY_BREAK(KEY_ENTER) && vpos == 1) ) {
vpos = 0;
state = ST_START;
continue;
}
} else if (state == ST_CLEAR_FLASH) {
bootloaderDrawScreen(state, 0);
lcdRefresh();
if(event != EVT_KEY_BREAK(KEY_ENTER))
continue;
flashSpiEraseAll();
vpos = 0;
state = ST_START;
#endif
} else if (state == ST_RADIO_MENU) {
if(bootloaderRadioMenu(radioMenuItem, event))
@@ -565,6 +603,6 @@ int bootloaderMain()
return 0;
}
#if !defined(SIMU) && (defined(PCBHORUS) || defined(PCBNV14))
#if !defined(SIMU) && (defined(PCBHORUS) || defined(PCBFLYSKY))
void *__dso_handle = nullptr;
#endif
@@ -54,6 +54,10 @@ enum BootloaderState {
ST_FLASH_DONE,
ST_RESTORE_MENU,
ST_USB,
#if defined(SPI_FLASH)
ST_CLEAR_FLASH_CHECK,
ST_CLEAR_FLASH,
#endif
ST_RADIO_MENU,
ST_REBOOT,
};