fix some bugs with sd spi (#320)
* change sd init speed * add pullup on bus
This commit is contained in:
parent
523f99f154
commit
63a1a4e4d7
@ -156,21 +156,21 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
|||||||
// SD Card need faster spi gpio
|
// SD Card need faster spi gpio
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = SPI_D_MOSI_Pin;
|
GPIO_InitStruct.Pin = SPI_D_MOSI_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||||
HAL_GPIO_Init(SPI_D_MOSI_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(SPI_D_MOSI_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = SPI_D_SCK_Pin;
|
GPIO_InitStruct.Pin = SPI_D_SCK_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||||
HAL_GPIO_Init(SPI_D_SCK_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(SPI_D_SCK_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
@ -37,7 +37,7 @@ const SPIDevice sd_slow_spi = {
|
|||||||
.CLKPolarity = SPI_POLARITY_LOW,
|
.CLKPolarity = SPI_POLARITY_LOW,
|
||||||
.CLKPhase = SPI_PHASE_1EDGE,
|
.CLKPhase = SPI_PHASE_1EDGE,
|
||||||
.NSS = SPI_NSS_SOFT,
|
.NSS = SPI_NSS_SOFT,
|
||||||
.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256,
|
.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32,
|
||||||
.FirstBit = SPI_FIRSTBIT_MSB,
|
.FirstBit = SPI_FIRSTBIT_MSB,
|
||||||
.TIMode = SPI_TIMODE_DISABLE,
|
.TIMode = SPI_TIMODE_DISABLE,
|
||||||
.CRCCalculation = SPI_CRCCALCULATION_DISABLE,
|
.CRCCalculation = SPI_CRCCALCULATION_DISABLE,
|
||||||
|
Loading…
Reference in New Issue
Block a user