diff --git a/os/hal/ports/STM32/LLD/SDMMCv2/hal_sdc_lld.c b/os/hal/ports/STM32/LLD/SDMMCv2/hal_sdc_lld.c index 66298b437..26ee52606 100644 --- a/os/hal/ports/STM32/LLD/SDMMCv2/hal_sdc_lld.c +++ b/os/hal/ports/STM32/LLD/SDMMCv2/hal_sdc_lld.c @@ -867,7 +867,9 @@ void sdc_lld_serve_interrupt(SDCDriver *sdcp) { read/write functions needs to check them.*/ sdcp->sdmmc->MASK = 0; + osalSysLockFromISR(); osalThreadResumeI(&sdcp->thread, MSG_OK); + osalSysUnlockFromISR(); } #endif /* HAL_USE_SDC */ diff --git a/testhal/STM32/multi/SDMMC-FATFS/main.c b/testhal/STM32/multi/SDMMC-FATFS/main.c index 1d8729ba4..d72461687 100644 --- a/testhal/STM32/multi/SDMMC-FATFS/main.c +++ b/testhal/STM32/multi/SDMMC-FATFS/main.c @@ -160,10 +160,12 @@ static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) { chprintf(chp, "Usage: tree\r\n"); return; } + if (!fs_ready) { chprintf(chp, "File System not mounted\r\n"); return; } + err = f_getfree("/", &fre_clust, &fsp); if (err != FR_OK) { chprintf(chp, "FS: f_getfree() failed\r\n"); @@ -176,8 +178,44 @@ static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) { scan_files(chp, (char *)fbuff); } +static void cmd_create(BaseSequentialStream *chp, int argc, char *argv[]) { + FRESULT err; + FIL f; + static const char data[] = "the quick brown fox jumps over the lazy dog"; + UINT btw = sizeof data - 1; + UINT bw; + + if (argc != 1) { + chprintf(chp, "Usage: create \r\n"); + return; + } + + if (!fs_ready) { + chprintf(chp, "File System not mounted\r\n"); + return; + } + + err = f_open(&f, (const TCHAR *)argv[0], FA_CREATE_ALWAYS | FA_WRITE); + if (err != FR_OK) { + chprintf(chp, "FS: f_open() failed\r\n"); + return; + } + + err = f_write(&f, (const void *)data, btw, &bw); + if (err != FR_OK) { + chprintf(chp, "FS: f_write() failed\r\n"); + } + + err = f_close(&f); + if (err != FR_OK) { + chprintf(chp, "FS: f_close() failed\r\n"); + return; + } +} + static const ShellCommand commands[] = { {"tree", cmd_tree}, + {"create", cmd_create}, {NULL, NULL} }; diff --git a/testhal/STM32/multi/SPI/debug/STM32-SPI (Select ELF file)(OpenOCD, Flash and Run).launch b/testhal/STM32/multi/SPI/debug/STM32-SPI (Select ELF file)(OpenOCD, Flash and Run).launch index c12d2b40f..9725fad62 100644 --- a/testhal/STM32/multi/SPI/debug/STM32-SPI (Select ELF file)(OpenOCD, Flash and Run).launch +++ b/testhal/STM32/multi/SPI/debug/STM32-SPI (Select ELF file)(OpenOCD, Flash and Run).launch @@ -33,7 +33,7 @@ - +