111 lines
3.1 KiB
C
111 lines
3.1 KiB
C
/**
|
|
******************************************************************************
|
|
* 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****/
|