Improve SDIO handling
This commit is contained in:
@@ -115,13 +115,20 @@ static inline void setup_shell_uart(struct stm_uart *uart)
|
||||
static bool mount_sd_card_if_avail(bool mounted)
|
||||
{
|
||||
FRESULT res;
|
||||
static uint8_t inserted_counter = 0;
|
||||
|
||||
if (sdio_check_inserted() && mounted) {
|
||||
memset(fs_ptr, 0, sizeof(FATFS));
|
||||
sdio_stop_clk();
|
||||
inserted_counter = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sdio_check_inserted() && !mounted) {
|
||||
if (!sdio_check_inserted() && inserted_counter < 255)
|
||||
inserted_counter++;
|
||||
|
||||
if (!sdio_check_inserted() && !mounted && inserted_counter > 4) {
|
||||
inserted_counter = 0;
|
||||
res = f_mount(fs_ptr, "0:/", 1);
|
||||
if (res == FR_OK)
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user