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.
140 lines
4.1 KiB
140 lines
4.1 KiB
/* USER CODE BEGIN Header */ |
|
/** |
|
****************************************************************************** |
|
* @file quadspi.c |
|
* @brief This file provides code for the configuration |
|
* of the QUADSPI 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 "quadspi.h" |
|
|
|
/* USER CODE BEGIN 0 */ |
|
|
|
/* USER CODE END 0 */ |
|
|
|
QSPI_HandleTypeDef hqspi; |
|
|
|
/* QUADSPI init function */ |
|
void MX_QUADSPI_Init(void) |
|
{ |
|
|
|
/* USER CODE BEGIN QUADSPI_Init 0 */ |
|
|
|
/* USER CODE END QUADSPI_Init 0 */ |
|
|
|
/* USER CODE BEGIN QUADSPI_Init 1 */ |
|
|
|
/* USER CODE END QUADSPI_Init 1 */ |
|
hqspi.Instance = QUADSPI; |
|
hqspi.Init.ClockPrescaler = 1; |
|
hqspi.Init.FifoThreshold = 1; |
|
hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; |
|
hqspi.Init.FlashSize = 24; |
|
hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_5_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(); |
|
} |
|
/* USER CODE BEGIN QUADSPI_Init 2 */ |
|
|
|
/* USER CODE END QUADSPI_Init 2 */ |
|
|
|
} |
|
|
|
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(); |
|
__HAL_RCC_GPIOF_CLK_ENABLE(); |
|
/**QUADSPI GPIO Configuration |
|
PB6 ------> QUADSPI_BK1_NCS |
|
PF7 ------> QUADSPI_BK1_IO2 |
|
PF6 ------> QUADSPI_BK1_IO3 |
|
PF10 ------> QUADSPI_CLK |
|
PF9 ------> QUADSPI_BK1_IO1 |
|
PF8 ------> QUADSPI_BK1_IO0 |
|
*/ |
|
GPIO_InitStruct.Pin = QSPI_BK1_NCS_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_AF10_QSPI; |
|
HAL_GPIO_Init(QSPI_BK1_NCS_GPIO_Port, &GPIO_InitStruct); |
|
|
|
GPIO_InitStruct.Pin = QSPI_BK1_IO2_Pin|QSPI_BK1_IO3_Pin|QSPI_CLK_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_AF9_QSPI; |
|
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); |
|
|
|
GPIO_InitStruct.Pin = QSPI_BK1_IO1_Pin|QSPI_BK1_IO0_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_AF10_QSPI; |
|
HAL_GPIO_Init(GPIOF, &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 |
|
PB6 ------> QUADSPI_BK1_NCS |
|
PF7 ------> QUADSPI_BK1_IO2 |
|
PF6 ------> QUADSPI_BK1_IO3 |
|
PF10 ------> QUADSPI_CLK |
|
PF9 ------> QUADSPI_BK1_IO1 |
|
PF8 ------> QUADSPI_BK1_IO0 |
|
*/ |
|
HAL_GPIO_DeInit(QSPI_BK1_NCS_GPIO_Port, QSPI_BK1_NCS_Pin); |
|
|
|
HAL_GPIO_DeInit(GPIOF, QSPI_BK1_IO2_Pin|QSPI_BK1_IO3_Pin|QSPI_CLK_Pin|QSPI_BK1_IO1_Pin |
|
|QSPI_BK1_IO0_Pin); |
|
|
|
/* USER CODE BEGIN QUADSPI_MspDeInit 1 */ |
|
|
|
/* USER CODE END QUADSPI_MspDeInit 1 */ |
|
} |
|
} |
|
|
|
/* USER CODE BEGIN 1 */ |
|
|
|
/* USER CODE END 1 */
|
|
|