Merge pull request #3340 from whj4674672/master
Porting for stm32h7xx spi
This commit is contained in:
commit
e5bd2884d7
|
@ -8,6 +8,7 @@
|
|||
* 2018-11-5 SummerGift first version
|
||||
* 2018-12-11 greedyhao Porting for stm32f7xx
|
||||
* 2019-01-03 zylx modify DMA initialization and spixfer function
|
||||
* 2020-01-15 whj4674672 Porting for stm32h7xx
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
|
@ -147,6 +148,8 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
|
|||
|
||||
#if defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32G0)
|
||||
SPI_APB_CLOCK = HAL_RCC_GetPCLK1Freq();
|
||||
#elif defined(SOC_SERIES_STM32H7)
|
||||
SPI_APB_CLOCK = HAL_RCC_GetSysClockFreq();
|
||||
#else
|
||||
SPI_APB_CLOCK = HAL_RCC_GetPCLK2Freq();
|
||||
#endif
|
||||
|
@ -205,6 +208,20 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
|
|||
spi_handle->State = HAL_SPI_STATE_RESET;
|
||||
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32G0) || defined(SOC_SERIES_STM32F0)
|
||||
spi_handle->Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
|
||||
#elif defined(SOC_SERIES_STM32H7)
|
||||
spi_handle->Init.Mode = SPI_MODE_MASTER;
|
||||
spi_handle->Init.NSS = SPI_NSS_SOFT;
|
||||
spi_handle->Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
|
||||
spi_handle->Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
|
||||
spi_handle->Init.CRCPolynomial = 7;
|
||||
spi_handle->Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
|
||||
spi_handle->Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
|
||||
spi_handle->Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
|
||||
spi_handle->Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
|
||||
spi_handle->Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
|
||||
spi_handle->Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_ENABLE;
|
||||
spi_handle->Init.IOSwap = SPI_IO_SWAP_DISABLE;
|
||||
spi_handle->Init.FifoThreshold = SPI_FIFO_THRESHOLD_08DATA;
|
||||
#endif
|
||||
|
||||
if (HAL_SPI_Init(spi_handle) != HAL_OK)
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
| **片上外设** | **支持情况** | **备注** |
|
||||
| GPIO | 支持 | PA0, PA1... PK15 ---> PIN: 0, 1...176 |
|
||||
| UART | 支持 | |
|
||||
| SPI | 暂不支持 | |
|
||||
| SPI | 支持 | SPI2 |
|
||||
| I2C | 暂不支持 | |
|
||||
| SDIO | 暂不支持 | |
|
||||
| RTC | 支持 | |
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -23,8 +23,9 @@ KeepUserPlacement=false
|
|||
Mcu.Family=STM32H7
|
||||
Mcu.IP0=CORTEX_M7
|
||||
Mcu.IP1=DEBUG
|
||||
Mcu.IP10=SYS
|
||||
Mcu.IP11=USART1
|
||||
Mcu.IP10=SPI2
|
||||
Mcu.IP11=SYS
|
||||
Mcu.IP12=USART1
|
||||
Mcu.IP2=DMA2D
|
||||
Mcu.IP3=FMC
|
||||
Mcu.IP4=IWDG1
|
||||
|
@ -33,7 +34,7 @@ Mcu.IP6=NVIC
|
|||
Mcu.IP7=QUADSPI
|
||||
Mcu.IP8=RCC
|
||||
Mcu.IP9=RTC
|
||||
Mcu.IPNb=12
|
||||
Mcu.IPNb=13
|
||||
Mcu.Name=STM32H743IITx
|
||||
Mcu.Package=LQFP176
|
||||
Mcu.Pin0=PC13
|
||||
|
@ -73,53 +74,56 @@ Mcu.Pin39=PH10
|
|||
Mcu.Pin4=PI10
|
||||
Mcu.Pin40=PH11
|
||||
Mcu.Pin41=PH12
|
||||
Mcu.Pin42=PD8
|
||||
Mcu.Pin43=PD9
|
||||
Mcu.Pin44=PD10
|
||||
Mcu.Pin45=PD14
|
||||
Mcu.Pin46=PD15
|
||||
Mcu.Pin47=PG2
|
||||
Mcu.Pin48=PG4
|
||||
Mcu.Pin49=PG5
|
||||
Mcu.Pin42=PB13
|
||||
Mcu.Pin43=PB14
|
||||
Mcu.Pin44=PB15
|
||||
Mcu.Pin45=PD8
|
||||
Mcu.Pin46=PD9
|
||||
Mcu.Pin47=PD10
|
||||
Mcu.Pin48=PD14
|
||||
Mcu.Pin49=PD15
|
||||
Mcu.Pin5=PF0
|
||||
Mcu.Pin50=PG6
|
||||
Mcu.Pin51=PG7
|
||||
Mcu.Pin52=PG8
|
||||
Mcu.Pin53=PA9
|
||||
Mcu.Pin54=PA10
|
||||
Mcu.Pin55=PA13 (JTMS/SWDIO)
|
||||
Mcu.Pin56=PH13
|
||||
Mcu.Pin57=PH14
|
||||
Mcu.Pin58=PH15
|
||||
Mcu.Pin59=PI0
|
||||
Mcu.Pin50=PG2
|
||||
Mcu.Pin51=PG4
|
||||
Mcu.Pin52=PG5
|
||||
Mcu.Pin53=PG6
|
||||
Mcu.Pin54=PG7
|
||||
Mcu.Pin55=PG8
|
||||
Mcu.Pin56=PA9
|
||||
Mcu.Pin57=PA10
|
||||
Mcu.Pin58=PA13 (JTMS/SWDIO)
|
||||
Mcu.Pin59=PH13
|
||||
Mcu.Pin6=PF1
|
||||
Mcu.Pin60=PI1
|
||||
Mcu.Pin61=PI2
|
||||
Mcu.Pin62=PA14 (JTCK/SWCLK)
|
||||
Mcu.Pin63=PD0
|
||||
Mcu.Pin64=PD1
|
||||
Mcu.Pin65=PG11
|
||||
Mcu.Pin66=PG15
|
||||
Mcu.Pin67=PB6
|
||||
Mcu.Pin68=PE0
|
||||
Mcu.Pin69=PE1
|
||||
Mcu.Pin60=PH14
|
||||
Mcu.Pin61=PH15
|
||||
Mcu.Pin62=PI0
|
||||
Mcu.Pin63=PI1
|
||||
Mcu.Pin64=PI2
|
||||
Mcu.Pin65=PA14 (JTCK/SWCLK)
|
||||
Mcu.Pin66=PD0
|
||||
Mcu.Pin67=PD1
|
||||
Mcu.Pin68=PG11
|
||||
Mcu.Pin69=PG15
|
||||
Mcu.Pin7=PF2
|
||||
Mcu.Pin70=PI4
|
||||
Mcu.Pin71=PI5
|
||||
Mcu.Pin72=PI6
|
||||
Mcu.Pin73=PI7
|
||||
Mcu.Pin74=VP_DMA2D_VS_DMA2D
|
||||
Mcu.Pin75=VP_IWDG1_VS_IWDG
|
||||
Mcu.Pin76=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin77=VP_SYS_VS_Systick
|
||||
Mcu.Pin70=PB6
|
||||
Mcu.Pin71=PE0
|
||||
Mcu.Pin72=PE1
|
||||
Mcu.Pin73=PI4
|
||||
Mcu.Pin74=PI5
|
||||
Mcu.Pin75=PI6
|
||||
Mcu.Pin76=PI7
|
||||
Mcu.Pin77=VP_DMA2D_VS_DMA2D
|
||||
Mcu.Pin78=VP_IWDG1_VS_IWDG
|
||||
Mcu.Pin79=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin8=PF3
|
||||
Mcu.Pin80=VP_SYS_VS_Systick
|
||||
Mcu.Pin9=PF4
|
||||
Mcu.PinsNb=78
|
||||
Mcu.PinsNb=81
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32H743IITx
|
||||
MxCube.Version=5.2.1
|
||||
MxDb.Version=DB.5.0.21
|
||||
MxCube.Version=5.3.0
|
||||
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.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
|
@ -141,6 +145,21 @@ PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK
|
|||
PA9.Locked=true
|
||||
PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
PB13.GPIOParameters=GPIO_Speed
|
||||
PB13.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB13.Locked=true
|
||||
PB13.Mode=Full_Duplex_Master
|
||||
PB13.Signal=SPI2_SCK
|
||||
PB14.GPIOParameters=GPIO_Speed
|
||||
PB14.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB14.Locked=true
|
||||
PB14.Mode=Full_Duplex_Master
|
||||
PB14.Signal=SPI2_MISO
|
||||
PB15.GPIOParameters=GPIO_Speed
|
||||
PB15.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB15.Locked=true
|
||||
PB15.Mode=Full_Duplex_Master
|
||||
PB15.Signal=SPI2_MOSI
|
||||
PB2.GPIOParameters=GPIO_Speed
|
||||
PB2.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
|
||||
PB2.Mode=Single Bank 1
|
||||
|
@ -288,10 +307,10 @@ ProjectManager.CompilerOptimize=6
|
|||
ProjectManager.ComputerToolchain=false
|
||||
ProjectManager.CoupleFile=false
|
||||
ProjectManager.CustomerFirmwarePackage=
|
||||
ProjectManager.DefaultFWLocation=false
|
||||
ProjectManager.DefaultFWLocation=true
|
||||
ProjectManager.DeletePrevious=true
|
||||
ProjectManager.DeviceId=STM32H743IITx
|
||||
ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.4.0
|
||||
ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.5.0
|
||||
ProjectManager.FreePins=false
|
||||
ProjectManager.HalAssertFull=false
|
||||
ProjectManager.HeapSize=0x200
|
||||
|
@ -308,7 +327,7 @@ 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_CORTEX_M7_Init-CORTEX_M7-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_DMA2D_Init-DMA2D-false-HAL-true,7-MX_LTDC_Init-LTDC-false-HAL-true,8-MX_RTC_Init-RTC-false-HAL-true,9-MX_IWDG1_Init-IWDG1-false-HAL-true,10-MX_QUADSPI_Init-QUADSPI-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_DMA2D_Init-DMA2D-false-HAL-true,7-MX_LTDC_Init-LTDC-false-HAL-true,8-MX_RTC_Init-RTC-false-HAL-true,9-MX_IWDG1_Init-IWDG1-false-HAL-true,10-MX_QUADSPI_Init-QUADSPI-false-HAL-true,11-MX_SPI2_Init-SPI2-false-HAL-true
|
||||
RCC.ADCFreq_Value=50390625
|
||||
RCC.AHB12Freq_Value=200000000
|
||||
RCC.AHB4Freq_Value=200000000
|
||||
|
@ -466,6 +485,12 @@ SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1
|
|||
SH.FMC_SDNRAS.ConfNb=1
|
||||
SH.FMC_SDNWE.0=FMC_SDNWE,13b-sda1
|
||||
SH.FMC_SDNWE.ConfNb=1
|
||||
SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4
|
||||
SPI2.CalculateBaudRate=100.0 MBits/s
|
||||
SPI2.Direction=SPI_DIRECTION_2LINES
|
||||
SPI2.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate
|
||||
SPI2.Mode=SPI_MODE_MASTER
|
||||
SPI2.VirtualType=VM_MASTER
|
||||
USART1.IPParameters=VirtualMode-Asynchronous
|
||||
USART1.VirtualMode-Asynchronous=VM_ASYNC
|
||||
VP_DMA2D_VS_DMA2D.Mode=DMA2D_Activate
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
/* #define HAL_SD_MODULE_ENABLED */
|
||||
/* #define HAL_MMC_MODULE_ENABLED */
|
||||
/* #define HAL_SPDIFRX_MODULE_ENABLED */
|
||||
/* #define HAL_SPI_MODULE_ENABLED */
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
/* #define HAL_SWPMI_MODULE_ENABLED */
|
||||
/* #define HAL_TIM_MODULE_ENABLED */
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
|
@ -78,12 +78,12 @@
|
|||
/* #define HAL_DSI_MODULE_ENABLED */
|
||||
/* #define HAL_JPEG_MODULE_ENABLED */
|
||||
/* #define HAL_MDIOS_MODULE_ENABLED */
|
||||
/* #define HAL_EXTI_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
#define HAL_MDMA_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
#define HAL_EXTI_MODULE_ENABLED
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
#define HAL_I2C_MODULE_ENABLED
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
|
|
|
@ -73,6 +73,8 @@ QSPI_HandleTypeDef hqspi;
|
|||
|
||||
RTC_HandleTypeDef hrtc;
|
||||
|
||||
SPI_HandleTypeDef hspi2;
|
||||
|
||||
UART_HandleTypeDef huart1;
|
||||
|
||||
SDRAM_HandleTypeDef hsdram1;
|
||||
|
@ -91,6 +93,7 @@ static void MX_LTDC_Init(void);
|
|||
static void MX_RTC_Init(void);
|
||||
static void MX_IWDG1_Init(void);
|
||||
static void MX_QUADSPI_Init(void);
|
||||
static void MX_SPI2_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
@ -142,6 +145,7 @@ int main(void)
|
|||
MX_RTC_Init();
|
||||
MX_IWDG1_Init();
|
||||
MX_QUADSPI_Init();
|
||||
MX_SPI2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
@ -221,8 +225,8 @@ void SystemClock_Config(void)
|
|||
Error_Handler();
|
||||
}
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_LTDC
|
||||
|RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_QSPI
|
||||
|RCC_PERIPHCLK_FMC;
|
||||
|RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_SPI2
|
||||
|RCC_PERIPHCLK_QSPI|RCC_PERIPHCLK_FMC;
|
||||
PeriphClkInitStruct.PLL3.PLL3M = 5;
|
||||
PeriphClkInitStruct.PLL3.PLL3N = 160;
|
||||
PeriphClkInitStruct.PLL3.PLL3P = 2;
|
||||
|
@ -233,6 +237,7 @@ void SystemClock_Config(void)
|
|||
PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
|
||||
PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK;
|
||||
PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK;
|
||||
PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
|
||||
PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2;
|
||||
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
||||
|
@ -457,6 +462,54 @@ static void MX_RTC_Init(void)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI2 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_SPI2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 0 */
|
||||
|
||||
/* USER CODE END SPI2_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 1 */
|
||||
|
||||
/* USER CODE END SPI2_Init 1 */
|
||||
/* SPI2 parameter configuration*/
|
||||
hspi2.Instance = SPI2;
|
||||
hspi2.Init.Mode = SPI_MODE_MASTER;
|
||||
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
hspi2.Init.DataSize = SPI_DATASIZE_4BIT;
|
||||
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi2.Init.NSS = SPI_NSS_SOFT;
|
||||
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
|
||||
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi2.Init.CRCPolynomial = 0x0;
|
||||
hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
|
||||
hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
|
||||
hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
|
||||
hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
|
||||
hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
|
||||
hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
|
||||
hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
|
||||
hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
|
||||
hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
|
||||
hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE;
|
||||
if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI2_Init 2 */
|
||||
|
||||
/* USER CODE END SPI2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USART1 Initialization Function
|
||||
* @param None
|
||||
|
|
|
@ -418,6 +418,73 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hspi->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspInit 0 */
|
||||
|
||||
/* USER CODE END SPI2_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_SPI2_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**SPI2 GPIO Configuration
|
||||
PB13 ------> SPI2_SCK
|
||||
PB14 ------> SPI2_MISO
|
||||
PB15 ------> SPI2_MOSI
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN SPI2_MspInit 1 */
|
||||
|
||||
/* USER CODE END SPI2_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
if(hspi->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END SPI2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SPI2_CLK_DISABLE();
|
||||
|
||||
/**SPI2 GPIO Configuration
|
||||
PB13 ------> SPI2_SCK
|
||||
PB14 ------> SPI2_MISO
|
||||
PB15 ------> SPI2_MOSI
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
|
||||
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SPI2_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
|
|
|
@ -54,6 +54,16 @@ menu "On-chip Peripheral Drivers"
|
|||
bool
|
||||
default n
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI BUS"
|
||||
default n
|
||||
select RT_USING_SPI
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI2
|
||||
bool "Enable SPI2 BUS"
|
||||
default n
|
||||
endif
|
||||
|
||||
config BSP_USING_QSPI
|
||||
bool "Enable QSPI BUS"
|
||||
select RT_USING_QSPI
|
||||
|
|
|
@ -70,8 +70,8 @@ void SystemClock_Config(void)
|
|||
Error_Handler();
|
||||
}
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_LTDC
|
||||
|RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_QSPI
|
||||
|RCC_PERIPHCLK_FMC;
|
||||
|RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_SPI2
|
||||
|RCC_PERIPHCLK_QSPI|RCC_PERIPHCLK_FMC;
|
||||
PeriphClkInitStruct.PLL3.PLL3M = 5;
|
||||
PeriphClkInitStruct.PLL3.PLL3N = 160;
|
||||
PeriphClkInitStruct.PLL3.PLL3P = 2;
|
||||
|
@ -82,6 +82,7 @@ void SystemClock_Config(void)
|
|||
PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
|
||||
PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK;
|
||||
PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK;
|
||||
PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
|
||||
PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2;
|
||||
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
||||
|
|
Loading…
Reference in New Issue