add qspi and sd on bearpi board
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -14,17 +14,19 @@ LPUART1.WordLength=UART_WORDLENGTH_8B
|
||||
Mcu.Family=STM32L4
|
||||
Mcu.IP0=ADC1
|
||||
Mcu.IP1=I2C1
|
||||
Mcu.IP10=USART2
|
||||
Mcu.IP11=USART3
|
||||
Mcu.IP10=SYS
|
||||
Mcu.IP11=USART1
|
||||
Mcu.IP12=USART2
|
||||
Mcu.IP13=USART3
|
||||
Mcu.IP2=LPUART1
|
||||
Mcu.IP3=NVIC
|
||||
Mcu.IP4=RCC
|
||||
Mcu.IP5=SPI1
|
||||
Mcu.IP6=SPI2
|
||||
Mcu.IP7=SPI3
|
||||
Mcu.IP8=SYS
|
||||
Mcu.IP9=USART1
|
||||
Mcu.IPNb=12
|
||||
Mcu.IP4=QUADSPI
|
||||
Mcu.IP5=RCC
|
||||
Mcu.IP6=SDMMC1
|
||||
Mcu.IP7=SPI1
|
||||
Mcu.IP8=SPI2
|
||||
Mcu.IP9=SPI3
|
||||
Mcu.IPNb=14
|
||||
Mcu.Name=STM32L431R(B-C)Tx
|
||||
Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PC13
|
||||
@@ -35,31 +37,38 @@ Mcu.Pin12=PA4
|
||||
Mcu.Pin13=PA6
|
||||
Mcu.Pin14=PC4
|
||||
Mcu.Pin15=PC5
|
||||
Mcu.Pin16=PB2
|
||||
Mcu.Pin17=PB13
|
||||
Mcu.Pin18=PB15
|
||||
Mcu.Pin19=PC6
|
||||
Mcu.Pin16=PB0
|
||||
Mcu.Pin17=PB1
|
||||
Mcu.Pin18=PB2
|
||||
Mcu.Pin19=PB10
|
||||
Mcu.Pin2=PC15-OSC32_OUT (PC15)
|
||||
Mcu.Pin20=PC7
|
||||
Mcu.Pin21=PA9
|
||||
Mcu.Pin22=PA10
|
||||
Mcu.Pin23=PA12
|
||||
Mcu.Pin24=PA15 (JTDI)
|
||||
Mcu.Pin25=PC10
|
||||
Mcu.Pin26=PC11
|
||||
Mcu.Pin27=PB3 (JTDO-TRACESWO)
|
||||
Mcu.Pin28=PB5
|
||||
Mcu.Pin29=PB6
|
||||
Mcu.Pin20=PB11
|
||||
Mcu.Pin21=PB13
|
||||
Mcu.Pin22=PB15
|
||||
Mcu.Pin23=PC6
|
||||
Mcu.Pin24=PC7
|
||||
Mcu.Pin25=PC8
|
||||
Mcu.Pin26=PA9
|
||||
Mcu.Pin27=PA10
|
||||
Mcu.Pin28=PA12
|
||||
Mcu.Pin29=PA15 (JTDI)
|
||||
Mcu.Pin3=PH0-OSC_IN (PH0)
|
||||
Mcu.Pin30=PB7
|
||||
Mcu.Pin31=VP_SYS_VS_Systick
|
||||
Mcu.Pin30=PC10
|
||||
Mcu.Pin31=PC11
|
||||
Mcu.Pin32=PC12
|
||||
Mcu.Pin33=PD2
|
||||
Mcu.Pin34=PB3 (JTDO-TRACESWO)
|
||||
Mcu.Pin35=PB5
|
||||
Mcu.Pin36=PB6
|
||||
Mcu.Pin37=PB7
|
||||
Mcu.Pin38=VP_SYS_VS_Systick
|
||||
Mcu.Pin4=PH1-OSC_OUT (PH1)
|
||||
Mcu.Pin5=PC0
|
||||
Mcu.Pin6=PC1
|
||||
Mcu.Pin7=PC2
|
||||
Mcu.Pin8=PC3
|
||||
Mcu.Pin9=PA1
|
||||
Mcu.PinsNb=32
|
||||
Mcu.PinsNb=39
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32L431RCTx
|
||||
@@ -68,6 +77,7 @@ MxDb.Version=DB.5.0.30
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.EXTI2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.LPUART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
@@ -101,6 +111,14 @@ PA6.Mode=Full_Duplex_Master
|
||||
PA6.Signal=SPI1_MISO
|
||||
PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
PB0.Mode=Single Bank 1 2IOs
|
||||
PB0.Signal=QUADSPI_BK1_IO1
|
||||
PB1.Mode=Single Bank 1 2IOs
|
||||
PB1.Signal=QUADSPI_BK1_IO0
|
||||
PB10.Mode=Single Bank 1 2IOs
|
||||
PB10.Signal=QUADSPI_CLK
|
||||
PB11.Mode=Single Bank 1 2IOs
|
||||
PB11.Signal=QUADSPI_BK1_NCS
|
||||
PB13.Locked=true
|
||||
PB13.Mode=TX_Only_Simplex_Unidirect_Master
|
||||
PB13.Signal=SPI2_SCK
|
||||
@@ -133,6 +151,8 @@ PC10.Mode=Full_Duplex_Master
|
||||
PC10.Signal=SPI3_SCK
|
||||
PC11.Mode=Full_Duplex_Master
|
||||
PC11.Signal=SPI3_MISO
|
||||
PC12.Mode=SD_1_bit
|
||||
PC12.Signal=SDMMC1_CK
|
||||
PC13.GPIOParameters=GPIO_Label
|
||||
PC13.GPIO_Label=LED
|
||||
PC13.Locked=true
|
||||
@@ -158,14 +178,10 @@ PC7.GPIOParameters=GPIO_Label
|
||||
PC7.GPIO_Label=LCD_RST
|
||||
PC7.Locked=true
|
||||
PC7.Signal=GPIO_Output
|
||||
PCC.Checker=true
|
||||
PCC.Line=STM32L4x1
|
||||
PCC.MCU=STM32L431R(B-C)Tx
|
||||
PCC.PartNumber=STM32L431RCTx
|
||||
PCC.Seq0=0
|
||||
PCC.Series=STM32L4
|
||||
PCC.Temperature=25
|
||||
PCC.Vdd=3.0
|
||||
PC8.Mode=SD_1_bit
|
||||
PC8.Signal=SDMMC1_D0
|
||||
PD2.Mode=SD_1_bit
|
||||
PD2.Signal=SDMMC1_CMD
|
||||
PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator
|
||||
PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN
|
||||
PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator
|
||||
@@ -193,11 +209,18 @@ ProjectManager.PreviousToolchain=
|
||||
ProjectManager.ProjectBuild=false
|
||||
ProjectManager.ProjectFileName=BearPi_STM32L31RC.ioc
|
||||
ProjectManager.ProjectName=BearPi_STM32L31RC
|
||||
ProjectManager.RegisterCallBack=
|
||||
ProjectManager.StackSize=0x400
|
||||
ProjectManager.TargetToolchain=MDK-ARM V5
|
||||
ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,6-MX_USART2_UART_Init-USART2-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_SPI2_Init-SPI2-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,6-MX_USART2_UART_Init-USART2-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_SPI2_Init-SPI2-false-HAL-true,11-MX_USART1_UART_Init-USART1-false-HAL-true,12-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,13-MX_QUADSPI_Init-QUADSPI-false-HAL-true
|
||||
QUADSPI.ChipSelectHighTime=QSPI_CS_HIGH_TIME_4_CYCLE
|
||||
QUADSPI.ClockPrescaler=0
|
||||
QUADSPI.FifoThreshold=4
|
||||
QUADSPI.FlashSize=22
|
||||
QUADSPI.IPParameters=ClockPrescaler,FifoThreshold,SampleShifting,FlashSize,ChipSelectHighTime
|
||||
QUADSPI.SampleShifting=QSPI_SAMPLE_SHIFTING_HALFCYCLE
|
||||
RCC.ADCFreq_Value=32000000
|
||||
RCC.AHBFreq_Value=80000000
|
||||
RCC.APB1Freq_Value=80000000
|
||||
|
58
board/BearPi_STM32L431RC/BSP/Inc/quadspi.h
Normal file
58
board/BearPi_STM32L431RC/BSP/Inc/quadspi.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : QUADSPI.h
|
||||
* Description : This file provides code for the configuration
|
||||
* of the QUADSPI instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __quadspi_H
|
||||
#define __quadspi_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern QSPI_HandleTypeDef hqspi;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_QUADSPI_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__ quadspi_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
58
board/BearPi_STM32L431RC/BSP/Inc/sdmmc.h
Normal file
58
board/BearPi_STM32L431RC/BSP/Inc/sdmmc.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : SDMMC.h
|
||||
* Description : This file provides code for the configuration
|
||||
* of the SDMMC instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __sdmmc_H
|
||||
#define __sdmmc_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern SD_HandleTypeDef hsd1;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_SDMMC1_SD_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__ sdmmc_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -78,11 +78,11 @@
|
||||
/*#define HAL_OSPI_MODULE_ENABLED */
|
||||
/*#define HAL_PCD_MODULE_ENABLED */
|
||||
/*#define HAL_QSPI_MODULE_ENABLED */
|
||||
/*#define HAL_QSPI_MODULE_ENABLED */
|
||||
#define HAL_QSPI_MODULE_ENABLED
|
||||
/*#define HAL_RNG_MODULE_ENABLED */
|
||||
/*#define HAL_RTC_MODULE_ENABLED */
|
||||
/*#define HAL_SAI_MODULE_ENABLED */
|
||||
/*#define HAL_SD_MODULE_ENABLED */
|
||||
#define HAL_SD_MODULE_ENABLED
|
||||
/*#define HAL_SMBUS_MODULE_ENABLED */
|
||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
|
@@ -103,21 +103,24 @@ void SystemClock_Config(void)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_USART3
|
||||
|RCC_PERIPHCLK_LPUART1|RCC_PERIPHCLK_I2C1
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART2
|
||||
|RCC_PERIPHCLK_USART3|RCC_PERIPHCLK_LPUART1
|
||||
|RCC_PERIPHCLK_I2C1|RCC_PERIPHCLK_SDMMC1
|
||||
|RCC_PERIPHCLK_ADC;
|
||||
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
|
||||
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
|
||||
PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
|
||||
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
|
||||
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
|
||||
PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;
|
||||
PeriphClkInit.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLLSAI1;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1N = 16;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_ADC1CLK;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK|RCC_PLLSAI1_ADC1CLK;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
|
110
board/BearPi_STM32L431RC/BSP/Src/quadspi.c
Normal file
110
board/BearPi_STM32L431RC/BSP/Src/quadspi.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : QUADSPI.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the QUADSPI instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "quadspi.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
QSPI_HandleTypeDef hqspi;
|
||||
|
||||
/* QUADSPI init function */
|
||||
void MX_QUADSPI_Init(void)
|
||||
{
|
||||
|
||||
hqspi.Instance = QUADSPI;
|
||||
hqspi.Init.ClockPrescaler = 0;
|
||||
hqspi.Init.FifoThreshold = 4;
|
||||
hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE;
|
||||
hqspi.Init.FlashSize = 22;
|
||||
hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_4_CYCLE;
|
||||
hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
|
||||
hqspi.Init.FlashID = QSPI_FLASH_ID_1;
|
||||
hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
|
||||
if (HAL_QSPI_Init(&hqspi) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void HAL_QSPI_MspInit(QSPI_HandleTypeDef* qspiHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(qspiHandle->Instance==QUADSPI)
|
||||
{
|
||||
/* USER CODE BEGIN QUADSPI_MspInit 0 */
|
||||
|
||||
/* USER CODE END QUADSPI_MspInit 0 */
|
||||
/* QUADSPI clock enable */
|
||||
__HAL_RCC_QSPI_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**QUADSPI GPIO Configuration
|
||||
PB0 ------> QUADSPI_BK1_IO1
|
||||
PB1 ------> QUADSPI_BK1_IO0
|
||||
PB10 ------> QUADSPI_CLK
|
||||
PB11 ------> QUADSPI_BK1_NCS
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_11;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN QUADSPI_MspInit 1 */
|
||||
|
||||
/* USER CODE END QUADSPI_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* qspiHandle)
|
||||
{
|
||||
|
||||
if(qspiHandle->Instance==QUADSPI)
|
||||
{
|
||||
/* USER CODE BEGIN QUADSPI_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END QUADSPI_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_QSPI_CLK_DISABLE();
|
||||
|
||||
/**QUADSPI GPIO Configuration
|
||||
PB0 ------> QUADSPI_BK1_IO1
|
||||
PB1 ------> QUADSPI_BK1_IO0
|
||||
PB10 ------> QUADSPI_CLK
|
||||
PB11 ------> QUADSPI_BK1_NCS
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_11);
|
||||
|
||||
/* USER CODE BEGIN QUADSPI_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END QUADSPI_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
117
board/BearPi_STM32L431RC/BSP/Src/sdmmc.c
Normal file
117
board/BearPi_STM32L431RC/BSP/Src/sdmmc.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : SDMMC.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the SDMMC instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "sdmmc.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
SD_HandleTypeDef hsd1;
|
||||
|
||||
/* SDMMC1 init function */
|
||||
|
||||
void MX_SDMMC1_SD_Init(void)
|
||||
{
|
||||
|
||||
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;
|
||||
if (HAL_SD_Init(&hsd1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
/**SDMMC1 GPIO Configuration
|
||||
PC8 ------> SDMMC1_D0
|
||||
PC12 ------> SDMMC1_CK
|
||||
PD2 ------> SDMMC1_CMD
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_12;
|
||||
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);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||
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(GPIOD, &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
|
||||
PC8 ------> SDMMC1_D0
|
||||
PC12 ------> SDMMC1_CK
|
||||
PD2 ------> SDMMC1_CMD
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8|GPIO_PIN_12);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
|
||||
|
||||
/* USER CODE BEGIN SDMMC1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SDMMC1_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
Reference in New Issue
Block a user