You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.5 KiB
130 lines
3.5 KiB
2 years ago
|
/* USER CODE BEGIN Header */
|
||
|
/**
|
||
|
******************************************************************************
|
||
|
* @file sdmmc.c
|
||
|
* @brief This file provides code for the configuration
|
||
|
* of the SDMMC instances.
|
||
|
******************************************************************************
|
||
|
* @attention
|
||
|
*
|
||
|
* Copyright (c) 2022 STMicroelectronics.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||
|
* in the root directory of this software component.
|
||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||
|
*
|
||
|
******************************************************************************
|
||
|
*/
|
||
|
/* USER CODE END Header */
|
||
|
/* Includes ------------------------------------------------------------------*/
|
||
|
#include "sdmmc.h"
|
||
|
|
||
|
/* USER CODE BEGIN 0 */
|
||
|
|
||
|
/* USER CODE END 0 */
|
||
|
|
||
|
SD_HandleTypeDef hsd1;
|
||
|
|
||
|
/* SDMMC1 init function */
|
||
|
|
||
|
void MX_SDMMC1_SD_Init(void)
|
||
|
{
|
||
|
|
||
|
/* USER CODE BEGIN SDMMC1_Init 0 */
|
||
|
|
||
|
/* USER CODE END SDMMC1_Init 0 */
|
||
|
|
||
|
/* USER CODE BEGIN SDMMC1_Init 1 */
|
||
|
|
||
|
/* USER CODE END SDMMC1_Init 1 */
|
||
|
hsd1.Instance = SDMMC1;
|
||
|
hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
|
||
|
hsd1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
|
||
|
hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
|
||
|
hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B;
|
||
|
hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
|
||
|
hsd1.Init.ClockDiv = 0;
|
||
|
/* USER CODE BEGIN SDMMC1_Init 2 */
|
||
|
|
||
|
/* USER CODE END SDMMC1_Init 2 */
|
||
|
|
||
|
}
|
||
|
|
||
|
void HAL_SD_MspInit(SD_HandleTypeDef* sdHandle)
|
||
|
{
|
||
|
|
||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||
|
if(sdHandle->Instance==SDMMC1)
|
||
|
{
|
||
|
/* USER CODE BEGIN SDMMC1_MspInit 0 */
|
||
|
|
||
|
/* USER CODE END SDMMC1_MspInit 0 */
|
||
|
/* SDMMC1 clock enable */
|
||
|
__HAL_RCC_SDMMC1_CLK_ENABLE();
|
||
|
|
||
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||
|
/**SDMMC1 GPIO Configuration
|
||
|
PD2 ------> SDMMC1_CMD
|
||
|
PC10 ------> SDMMC1_D2
|
||
|
PC11 ------> SDMMC1_D3
|
||
|
PC12 ------> SDMMC1_CK
|
||
|
PC9 ------> SDMMC1_D1
|
||
|
PC8 ------> SDMMC1_D0
|
||
|
*/
|
||
|
GPIO_InitStruct.Pin = uSD_CMD_Pin;
|
||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||
|
GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
|
||
|
HAL_GPIO_Init(uSD_CMD_GPIO_Port, &GPIO_InitStruct);
|
||
|
|
||
|
GPIO_InitStruct.Pin = uSD_D2_Pin|uSD_D3_Pin|uSD_CLK_Pin|uSD_D1_Pin
|
||
|
|uSD_D0_Pin;
|
||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||
|
GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
|
||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||
|
|
||
|
/* USER CODE BEGIN SDMMC1_MspInit 1 */
|
||
|
|
||
|
/* USER CODE END SDMMC1_MspInit 1 */
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void HAL_SD_MspDeInit(SD_HandleTypeDef* sdHandle)
|
||
|
{
|
||
|
|
||
|
if(sdHandle->Instance==SDMMC1)
|
||
|
{
|
||
|
/* USER CODE BEGIN SDMMC1_MspDeInit 0 */
|
||
|
|
||
|
/* USER CODE END SDMMC1_MspDeInit 0 */
|
||
|
/* Peripheral clock disable */
|
||
|
__HAL_RCC_SDMMC1_CLK_DISABLE();
|
||
|
|
||
|
/**SDMMC1 GPIO Configuration
|
||
|
PD2 ------> SDMMC1_CMD
|
||
|
PC10 ------> SDMMC1_D2
|
||
|
PC11 ------> SDMMC1_D3
|
||
|
PC12 ------> SDMMC1_CK
|
||
|
PC9 ------> SDMMC1_D1
|
||
|
PC8 ------> SDMMC1_D0
|
||
|
*/
|
||
|
HAL_GPIO_DeInit(uSD_CMD_GPIO_Port, uSD_CMD_Pin);
|
||
|
|
||
|
HAL_GPIO_DeInit(GPIOC, uSD_D2_Pin|uSD_D3_Pin|uSD_CLK_Pin|uSD_D1_Pin
|
||
|
|uSD_D0_Pin);
|
||
|
|
||
|
/* USER CODE BEGIN SDMMC1_MspDeInit 1 */
|
||
|
|
||
|
/* USER CODE END SDMMC1_MspDeInit 1 */
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* USER CODE BEGIN 1 */
|
||
|
|
||
|
/* USER CODE END 1 */
|