Fixed SPI settings, to be tested.
@@ -50,16 +50,19 @@ | ||
50 | 50 | /* Module exported functions. */ |
51 | 51 | /*===========================================================================*/ |
52 | 52 | |
53 | -void spi_error_cb(SPIDriver *spip); | |
53 | +/* Making sure mcuconf.h setup is as expected.*/ | |
54 | +#if STM32_PCLK1 != 85000000 | |
55 | +#error "unexpected PCLK1 frequency" | |
56 | +#endif | |
54 | 57 | |
55 | 58 | /* |
56 | - * High speed SPI configuration (21.25MHz, CPHA=0, CPOL=0, MSb first). | |
59 | + * High speed SPI configuration (PCLK1/4=21.25MHz, CPHA=0, CPOL=0, MSb first). | |
57 | 60 | */ |
58 | 61 | const SPIConfig hs_spicfg = { |
59 | 62 | .circular = false, |
60 | 63 | .slave = false, |
61 | 64 | .data_cb = NULL, |
62 | - .error_cb = spi_error_cb, | |
65 | + .error_cb = NULL, | |
63 | 66 | .ssport = GPIOB, |
64 | 67 | .sspad = 12U, |
65 | 68 | .cr1 = SPI_CR1_BR_0, |
@@ -67,16 +70,16 @@ | ||
67 | 70 | }; |
68 | 71 | |
69 | 72 | /* |
70 | - * Low speed SPI configuration (664,062kHz, CPHA=0, CPOL=0, MSb first). | |
73 | + * Low speed SPI configuration (PCLK1/32=265.6250kHz, CPHA=0, CPOL=0, MSb first). | |
71 | 74 | */ |
72 | 75 | const SPIConfig ls_spicfg = { |
73 | 76 | .circular = false, |
74 | 77 | .slave = false, |
75 | 78 | .data_cb = NULL, |
76 | - .error_cb = spi_error_cb, | |
79 | + .error_cb = NULL, | |
77 | 80 | .ssport = GPIOB, |
78 | 81 | .sspad = 12U, |
79 | - .cr1 = SPI_CR1_BR_2 | SPI_CR1_BR_1, | |
82 | + .cr1 = SPI_CR1_BR_2, | |
80 | 83 | .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 |
81 | 84 | }; |
82 | 85 |
@@ -37,6 +37,7 @@ | ||
37 | 37 | #define PORTAB_BUTTON_PRESSED PAL_HIGH |
38 | 38 | |
39 | 39 | #define PORTAB_SD1 LPSD1 |
40 | +#define PORTAB_SPI1 SPID2 | |
40 | 41 | |
41 | 42 | /*===========================================================================*/ |
42 | 43 | /* Module pre-compile time settings. */ |
@@ -58,6 +59,9 @@ | ||
58 | 59 | /* External declarations. */ |
59 | 60 | /*===========================================================================*/ |
60 | 61 | |
62 | +extern const SPIConfig hs_spicfg; | |
63 | +extern const SPIConfig ls_spicfg; | |
64 | + | |
61 | 65 | #ifdef __cplusplus |
62 | 66 | extern "C" { |
63 | 67 | #endif |
@@ -153,6 +153,9 @@ | ||
153 | 153 | |
154 | 154 | #if !HAL_USE_SDC |
155 | 155 | mmc_spi_driver_t MMCD1; |
156 | + | |
157 | +/* MMC/SD over SPI driver configuration.*/ | |
158 | +static MMCConfig mmccfg = {&SPID2, &ls_spicfg, &hs_spicfg}; | |
156 | 159 | #endif |
157 | 160 | |
158 | 161 | /* |
@@ -278,7 +281,8 @@ | ||
278 | 281 | /* Activates the card insertion monitor.*/ |
279 | 282 | tmr_init(&PORTAB_SDCD1); |
280 | 283 | #else |
281 | - /* TODO MMC_SPI */ | |
284 | + mmcObjectInit(&MMCD1); | |
285 | + mmcStart(&MMCD1, &mmccfg); | |
282 | 286 | |
283 | 287 | /* Activates the card insertion monitor.*/ |
284 | 288 | tmr_init(&MMCD1); |