[X9D] SD Card working
This commit is contained in:
+18
-22
@@ -451,25 +451,6 @@ void power_on (void)
|
|||||||
|
|
||||||
for (Timer1 = 25; Timer1; ); /* Wait for 250ms */
|
for (Timer1 = 25; Timer1; ); /* Wait for 250ms */
|
||||||
|
|
||||||
/* Configure I/O for Flash Chip select */
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SPI_SD_CS;
|
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_Init(GPIO_SPI_SD, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
/* De-select the Card: Chip Select high */
|
|
||||||
DESELECT();
|
|
||||||
|
|
||||||
/* Configure SPI pins: SCK MISO and MOSI with alternate function push-down */
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SPI_SD_SCK | GPIO_Pin_SPI_SD_MOSI | GPIO_Pin_SPI_SD_MISO;
|
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
|
|
||||||
GPIO_Init(GPIO_SPI_SD, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
/* SPI configuration */
|
/* SPI configuration */
|
||||||
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
||||||
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
|
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
|
||||||
@@ -485,9 +466,24 @@ void power_on (void)
|
|||||||
SPI_CalculateCRC(SPI_SD, DISABLE);
|
SPI_CalculateCRC(SPI_SD, DISABLE);
|
||||||
SPI_Cmd(SPI_SD, ENABLE);
|
SPI_Cmd(SPI_SD, ENABLE);
|
||||||
|
|
||||||
/* drain SPI */
|
/* De-select the Card: Chip Select high */
|
||||||
while (SPI_I2S_GetFlagStatus(SPI_SD, SPI_I2S_FLAG_TXE) == RESET) { ; }
|
DESELECT();
|
||||||
dummyread = SPI_I2S_ReceiveData(SPI_SD);
|
|
||||||
|
/* Configure I/O for Flash Chip select */
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SPI_SD_CS;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||||
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(GPIO_SPI_SD, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
/* Configure SPI pins: SCK MISO and MOSI with alternate function push-down */
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SPI_SD_SCK | GPIO_Pin_SPI_SD_MOSI | GPIO_Pin_SPI_SD_MISO;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||||
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||||
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||||
|
GPIO_Init(GPIO_SPI_SD, &GPIO_InitStructure);
|
||||||
|
|
||||||
#ifdef STM32_SD_USE_DMA
|
#ifdef STM32_SD_USE_DMA
|
||||||
/* enable DMA clock */
|
/* enable DMA clock */
|
||||||
|
|||||||
Reference in New Issue
Block a user