diff --git a/demos/STM32/RT-VFS-FATFS/cfg/stm32g474re_nucleo64/portab.c b/demos/STM32/RT-VFS-FATFS/cfg/stm32g474re_nucleo64/portab.c index 550db6f3b..34ce3017a 100644 --- a/demos/STM32/RT-VFS-FATFS/cfg/stm32g474re_nucleo64/portab.c +++ b/demos/STM32/RT-VFS-FATFS/cfg/stm32g474re_nucleo64/portab.c @@ -50,16 +50,19 @@ /* Module exported functions. */ /*===========================================================================*/ -void spi_error_cb(SPIDriver *spip); +/* Making sure mcuconf.h setup is as expected.*/ +#if STM32_PCLK1 != 85000000 +#error "unexpected PCLK1 frequency" +#endif /* - * High speed SPI configuration (21.25MHz, CPHA=0, CPOL=0, MSb first). + * High speed SPI configuration (PCLK1/4=21.25MHz, CPHA=0, CPOL=0, MSb first). */ const SPIConfig hs_spicfg = { .circular = false, .slave = false, .data_cb = NULL, - .error_cb = spi_error_cb, + .error_cb = NULL, .ssport = GPIOB, .sspad = 12U, .cr1 = SPI_CR1_BR_0, @@ -67,16 +70,16 @@ const SPIConfig hs_spicfg = { }; /* - * Low speed SPI configuration (664,062kHz, CPHA=0, CPOL=0, MSb first). + * Low speed SPI configuration (PCLK1/32=265.6250kHz, CPHA=0, CPOL=0, MSb first). */ const SPIConfig ls_spicfg = { .circular = false, .slave = false, .data_cb = NULL, - .error_cb = spi_error_cb, + .error_cb = NULL, .ssport = GPIOB, .sspad = 12U, - .cr1 = SPI_CR1_BR_2 | SPI_CR1_BR_1, + .cr1 = SPI_CR1_BR_2, .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 }; diff --git a/demos/STM32/RT-VFS-FATFS/cfg/stm32g474re_nucleo64/portab.h b/demos/STM32/RT-VFS-FATFS/cfg/stm32g474re_nucleo64/portab.h index f198ef6a9..97eede3b0 100644 --- a/demos/STM32/RT-VFS-FATFS/cfg/stm32g474re_nucleo64/portab.h +++ b/demos/STM32/RT-VFS-FATFS/cfg/stm32g474re_nucleo64/portab.h @@ -37,6 +37,7 @@ #define PORTAB_BUTTON_PRESSED PAL_HIGH #define PORTAB_SD1 LPSD1 +#define PORTAB_SPI1 SPID2 /*===========================================================================*/ /* Module pre-compile time settings. */ @@ -58,6 +59,9 @@ /* External declarations. */ /*===========================================================================*/ +extern const SPIConfig hs_spicfg; +extern const SPIConfig ls_spicfg; + #ifdef __cplusplus extern "C" { #endif diff --git a/demos/STM32/RT-VFS-FATFS/main.c b/demos/STM32/RT-VFS-FATFS/main.c index ca76ede37..ec08f9298 100644 --- a/demos/STM32/RT-VFS-FATFS/main.c +++ b/demos/STM32/RT-VFS-FATFS/main.c @@ -153,6 +153,9 @@ static ShellConfig shell_cfg1 = { #if !HAL_USE_SDC mmc_spi_driver_t MMCD1; + +/* MMC/SD over SPI driver configuration.*/ +static MMCConfig mmccfg = {&SPID2, &ls_spicfg, &hs_spicfg}; #endif /* @@ -278,7 +281,8 @@ int main(void) { /* Activates the card insertion monitor.*/ tmr_init(&PORTAB_SDCD1); #else - /* TODO MMC_SPI */ + mmcObjectInit(&MMCD1); + mmcStart(&MMCD1, &mmccfg); /* Activates the card insertion monitor.*/ tmr_init(&MMCD1);