chore: SDIO conversion to HAL (#3182)

This commit is contained in:
Malte Langermann
2023-08-13 18:56:39 +02:00
committed by GitHub
parent 3342d21195
commit b377a8b5d4
36 changed files with 830 additions and 3013 deletions
@@ -25,7 +25,6 @@ set(BOOTLOADER_SRC
../../../../../${FATFS_DIR}/ffunicode.c
../../../../../targets/${TARGET_DIR}/${LCD_DRIVER}
../../../../../targets/${TARGET_DIR}/backlight_driver.cpp
../../../../../targets/${TARGET_DIR}/diskio.cpp
../../../../../targets/${TARGET_DIR}/board.cpp
../../../../../targets/${TARGET_DIR}/bootloader/boot_menu.cpp
${CMAKE_CURRENT_BINARY_DIR}/hal_keys.inc
@@ -42,6 +41,7 @@ set(BOOTLOADER_SRC
../stm32_serial_driver.cpp
../stm32_usart_driver.cpp
../stm32_gpio_driver.cpp
../stm32_dma.cpp
init.c
boot.cpp
bin_files.cpp
@@ -77,7 +77,8 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
../../../../../fonts/lvgl/lv_font_roboto_bl_16.c
../../../../../thirdparty/libopenui/src/bitmapbuffer.cpp
../../../../../thirdparty/libopenui/thirdparty/lz4/lz4.c
../../../../../targets/common/arm/stm32/sdio_sd.c
../../../../../targets/common/arm/stm32/sdio_sd.cpp
../../../../../targets/common/arm/stm32/diskio_sdio.cpp
../../../../../targets/common/arm/stm32/rtc_driver.cpp
../../../../../targets/${TARGET_DIR}/sdram_driver.c
../../../../../targets/${TARGET_DIR}/haptic_driver.cpp
@@ -119,6 +120,7 @@ else()
../../../../../gui/common/stdlcd/fonts.cpp
../../../../../gui/common/stdlcd/utf8.cpp
../../../../../targets/${TARGET_DIR}/eeprom_driver.cpp
../../../../../targets/${TARGET_DIR}/diskio.cpp
)
remove_definitions(-DDEBUG)
endif()
@@ -38,6 +38,14 @@ BinFileInfo binFiles[MAX_BIN_FILES];
uint8_t Block_buffer[BLOCK_LEN];
UINT BlockCount;
void sdInit(void)
{
static FATFS fatFS __DMA;
if (f_mount(&fatFS, "", 1) == FR_OK) {
f_chdir("/");
}
}
FRESULT openBinDir(MemoryType mt)
{
@@ -94,9 +94,12 @@ uint32_t eepromWritten = 0;
FlashCheckRes valid;
MemoryType memoryType;
uint32_t unlocked = 0;
uint32_t timer10MsCount;
void interrupt10ms()
{
timer10MsCount++;
tenms |= 1u; // 10 mS has passed
g_tmr10ms++;
@@ -116,6 +119,7 @@ void interrupt10ms()
void init10msTimer()
{
timer10MsCount = 0;
INTERRUPT_xMS_TIMER->ARR = 9999; // 10mS in uS
INTERRUPT_xMS_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1; // 1uS
INTERRUPT_xMS_TIMER->CCER = 0;
@@ -126,6 +130,11 @@ void init10msTimer()
NVIC_EnableIRQ(INTERRUPT_xMS_IRQn);
}
extern "C" uint32_t HAL_GetTick(void)
{
return timer10MsCount*10;
}
#if !defined(SIMU)
extern "C" void INTERRUPT_xMS_IRQHandler()
{
@@ -188,8 +197,6 @@ int menuFlashFile(uint32_t index, event_t event)
return -1;
}
static uint32_t PowerUpDelay;
void flashWriteBlock()
{
uint32_t blockOffset = 0;
@@ -571,12 +578,16 @@ int bootloaderMain()
lcdRefresh();
#if defined(SDCARD) && defined(PCBTARANIS)
static uint32_t PowerUpDelay = 0;
if (PowerUpDelay < 20) { // 200 mS
PowerUpDelay += 1;
}
else {
sdPoll10ms();
}
#endif
}
if (state != ST_FLASHING && state != ST_USB) {