Fixed SPI settings, to be tested.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15847 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2022-11-22 16:26:48 +00:00
parent d4845d8b7c
commit 239366ca0a
3 changed files with 18 additions and 7 deletions

View File

@ -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
};

View File

@ -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

View File

@ -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);