提交 3c9da16d 编写于 作者: liuduanfei's avatar liuduanfei

Add SD Card driver for stm32h743-atk-apollo board

上级 d1a12288
......@@ -107,6 +107,10 @@ CONFIG_FINSH_ARG_MAX=10
# Device virtual file system
#
# CONFIG_RT_USING_DFS is not set
# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_3 is not set
#
# Device Drivers
......
......@@ -438,51 +438,51 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
* @param hsd: SD handle pointer
* @retval None
*/
//void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
//{
// GPIO_InitTypeDef GPIO_InitStruct = {0};
// if(hsd->Instance==SDMMC1)
// {
// /* USER CODE BEGIN SDMMC1_MspInit 0 */
// /* USER CODE END SDMMC1_MspInit 0 */
// /* Peripheral clock enable */
// __HAL_RCC_SDMMC1_CLK_ENABLE();
//
// __HAL_RCC_GPIOC_CLK_ENABLE();
// __HAL_RCC_GPIOD_CLK_ENABLE();
// /**SDMMC1 GPIO Configuration
// PC8 ------> SDMMC1_D0
// PC9 ------> SDMMC1_D1
// PC10 ------> SDMMC1_D2
// PC11 ------> SDMMC1_D3
// PC12 ------> SDMMC1_CK
// PD2 ------> SDMMC1_CMD
// */
// GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
// |GPIO_PIN_12;
// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
// GPIO_InitStruct.Pull = GPIO_NOPULL;
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
// GPIO_InitStruct.Alternate = GPIO_AF12_SDIO1;
// HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
// GPIO_InitStruct.Pin = GPIO_PIN_2;
// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
// GPIO_InitStruct.Pull = GPIO_NOPULL;
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
// GPIO_InitStruct.Alternate = GPIO_AF12_SDIO1;
// HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
// /* SDMMC1 interrupt Init */
// HAL_NVIC_SetPriority(SDMMC1_IRQn, 2, 0);
// HAL_NVIC_EnableIRQ(SDMMC1_IRQn);
// /* USER CODE BEGIN SDMMC1_MspInit 1 */
// /* USER CODE END SDMMC1_MspInit 1 */
// }
//}
void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hsd->Instance==SDMMC1)
{
/* USER CODE BEGIN SDMMC1_MspInit 0 */
/* USER CODE END SDMMC1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_SDMMC1_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/**SDMMC1 GPIO Configuration
PC8 ------> SDMMC1_D0
PC9 ------> SDMMC1_D1
PC10 ------> SDMMC1_D2
PC11 ------> SDMMC1_D3
PC12 ------> SDMMC1_CK
PD2 ------> SDMMC1_CMD
*/
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO1;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO1;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/* SDMMC1 interrupt Init */
HAL_NVIC_SetPriority(SDMMC1_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(SDMMC1_IRQn);
/* USER CODE BEGIN SDMMC1_MspInit 1 */
/* USER CODE END SDMMC1_MspInit 1 */
}
}
/**
* @brief SD MSP De-Initialization
......
......@@ -433,35 +433,11 @@ void SDMMC1_IRQHandler(void)
rt_interrupt_leave();
}
void HAL_SD_MspInit(SD_HandleTypeDef * hsd)
{
GPIO_InitTypeDef GPIO_Initure;
__HAL_RCC_SDMMC1_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/* PC8,9,10,11,12 */
GPIO_Initure.Pin=GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
GPIO_Initure.Mode=GPIO_MODE_AF_PP;
GPIO_Initure.Pull=GPIO_NOPULL;
GPIO_Initure.Speed=GPIO_SPEED_FREQ_HIGH;
GPIO_Initure.Alternate=GPIO_AF12_SDIO1;
HAL_GPIO_Init(GPIOC,&GPIO_Initure);
/* PD2 */
GPIO_Initure.Pin=GPIO_PIN_2;
HAL_GPIO_Init(GPIOD,&GPIO_Initure);
HAL_NVIC_SetPriority(SDMMC1_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(SDMMC1_IRQn);
}
int rt_hw_sdio_init(void)
{
struct stm32_sdio_des sdio_des;
SD_HandleTypeDef hsd;
hsd.Instance = SDMMC1;
HAL_SD_MspInit(&hsd);
host = sdio_host_create(&sdio_des);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册