60#ifndef STM32H747I_EVAL_QSPI_H
61#define STM32H747I_EVAL_QSPI_H
68#include "stm32h747i_eval_conf.h"
70#include "../Components/mt25tl01g/mt25tl01g.h"
87#define BSP_QSPI_Info_t MT25TL01G_Info_t
88#define BSP_QSPI_Interface_t MT25TL01G_Interface_t
89#define BSP_QSPI_Transfer_t MT25TL01G_Transfer_t
90#define BSP_QSPI_DualFlash_t MT25TL01G_DualFlash_t
91#define BSP_QSPI_ODS_t MT25TL01G_ODS_t
115 uint32_t IsMspCallbacksValid;
128 uint32_t ClockPrescaler;
129 uint32_t SampleShifting;
130 uint32_t DualFlashMode;
132#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
135 void(*pMspInitCb)(pQSPI_CallbackTypeDef);
136 void(*pMspDeInitCb)(pQSPI_CallbackTypeDef);
149#define QSPI_INSTANCES_NUMBER 1U
152#define BSP_QSPI_SPI_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_MODE
153#define BSP_QSPI_SPI_1I2O_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_1I2O_MODE
154#define BSP_QSPI_SPI_2IO_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_2IO_MODE
155#define BSP_QSPI_SPI_1I4O_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_1I4O_MODE
156#define BSP_QSPI_SPI_4IO_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_4IO_MODE
157#define BSP_QSPI_DPI_MODE (BSP_QSPI_Interface_t)MT25TL01G_DPI_MODE
158#define BSP_QSPI_QPI_MODE (BSP_QSPI_Interface_t)MT25TL01G_QPI_MODE
161#define BSP_QSPI_STR_TRANSFER (BSP_QSPI_Transfer_t)MT25TL01G_STR_TRANSFER
162#define BSP_QSPI_DTR_TRANSFER (BSP_QSPI_Transfer_t)MT25TL01G_DTR_TRANSFER
165#define BSP_QSPI_DUALFLASH_DISABLE (BSP_QSPI_DualFlash_t)MT25TL01G_DUALFLASH_DISABLE
167#define BSP_QSPI_FLASH_ID QSPI_FLASH_ID_1
170#define BSP_QSPI_BLOCK_8K MT25TL01G_SECTOR_4K
171#define BSP_QSPI_BLOCK_64K MT25TL01G_BLOCK_32K
172#define BSP_QSPI_BLOCK_128K MT25TL01G_BLOCK_64K
175#define QSPI_CLK_ENABLE() __HAL_RCC_QSPI_CLK_ENABLE()
176#define QSPI_CLK_DISABLE() __HAL_RCC_QSPI_CLK_DISABLE()
177#define QSPI_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
178#define QSPI_BK1_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
179#define QSPI_BK1_D0_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
180#define QSPI_BK1_D1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
181#define QSPI_BK1_D2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
182#define QSPI_BK1_D3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
183#define QSPI_BK2_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
184#define QSPI_BK2_D0_GPIO_CLK_ENABLE() __HAL_RCC_GPIOH_CLK_ENABLE()
185#define QSPI_BK2_D1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOH_CLK_ENABLE()
186#define QSPI_BK2_D2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
187#define QSPI_BK2_D3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
190#define QSPI_FORCE_RESET() __HAL_RCC_QSPI_FORCE_RESET()
191#define QSPI_RELEASE_RESET() __HAL_RCC_QSPI_RELEASE_RESET()
194#define QSPI_CLK_PIN GPIO_PIN_2
195#define QSPI_CLK_GPIO_PORT GPIOB
197#define QSPI_BK1_CS_PIN GPIO_PIN_6
198#define QSPI_BK1_CS_GPIO_PORT GPIOG
199#define QSPI_BK1_D0_PIN GPIO_PIN_8
200#define QSPI_BK1_D0_GPIO_PORT GPIOF
201#define QSPI_BK1_D1_PIN GPIO_PIN_9
202#define QSPI_BK1_D1_GPIO_PORT GPIOF
203#define QSPI_BK1_D2_PIN GPIO_PIN_7
204#define QSPI_BK1_D2_GPIO_PORT GPIOF
205#define QSPI_BK1_D3_PIN GPIO_PIN_6
206#define QSPI_BK1_D3_GPIO_PORT GPIOF
209#define QSPI_BK2_CS_PIN GPIO_PIN_11
210#define QSPI_BK2_CS_GPIO_PORT GPIOC
211#define QSPI_BK2_D0_PIN GPIO_PIN_2
212#define QSPI_BK2_D0_GPIO_PORT GPIOH
213#define QSPI_BK2_D1_PIN GPIO_PIN_3
214#define QSPI_BK2_D1_GPIO_PORT GPIOH
215#define QSPI_BK2_D2_PIN GPIO_PIN_9
216#define QSPI_BK2_D2_GPIO_PORT GPIOG
217#define QSPI_BK2_D3_PIN GPIO_PIN_14
218#define QSPI_BK2_D3_GPIO_PORT GPIOG
223#define QSPI_FLASH_SIZE 26
224#define QSPI_PAGE_SIZE 256
227#define QSPI_BASE_ADDRESS 0x90000000
235extern QSPI_HandleTypeDef hqspi;
247#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
248int32_t BSP_QSPI_RegisterMspCallbacks (uint32_t Instance, BSP_QSPI_Cb_t *CallBacks);
249int32_t BSP_QSPI_RegisterDefaultMspCallbacks (uint32_t Instance);
251int32_t
BSP_QSPI_Read(uint32_t Instance, uint8_t *pData, uint32_t ReadAddr, uint32_t Size);
252int32_t
BSP_QSPI_Write(uint32_t Instance, uint8_t *pData, uint32_t WriteAddr, uint32_t Size);
260int32_t
BSP_QSPI_ConfigFlash(uint32_t Instance, BSP_QSPI_Interface_t Mode, BSP_QSPI_Transfer_t Rate);
@ MT25TL01G_ERASE_32K
Definition: mt25tl01g.h:111
@ MT25TL01G_ERASE_64K
Definition: mt25tl01g.h:112
@ MT25TL01G_ERASE_CHIP
Definition: mt25tl01g.h:113
@ MT25TL01G_ERASE_4K
Definition: mt25tl01g.h:110
int32_t BSP_QSPI_EraseBlock(uint32_t Instance, uint32_t BlockAddress, BSP_QSPI_Erase_t BlockSize)
Erases the specified block of the QSPI memory. MT25TL01G support 4K, 32K, 64K size block erase comman...
Definition: stm32h747i_eval_qspi.c:490
int32_t BSP_QSPI_Read(uint32_t Instance, uint8_t *pData, uint32_t ReadAddr, uint32_t Size)
Reads an amount of data from the QSPI memory.
Definition: stm32h747i_eval_qspi.c:381
int32_t BSP_QSPI_EnableMemoryMappedMode(uint32_t Instance)
Configure the QSPI in memory-mapped mode Only 1 Instance can running MMP mode. And it will lock syste...
Definition: stm32h747i_eval_qspi.c:629
int32_t BSP_QSPI_Write(uint32_t Instance, uint8_t *pData, uint32_t WriteAddr, uint32_t Size)
Writes an amount of data to the QSPI memory.
Definition: stm32h747i_eval_qspi.c:420
__weak HAL_StatusTypeDef MX_QSPI_Init(QSPI_HandleTypeDef *hQspi, MX_QSPI_Init_t *Config)
Initializes the QSPI interface.
Definition: stm32h747i_eval_qspi.c:283
int32_t BSP_QSPI_Init(uint32_t Instance, BSP_QSPI_Init_t *Init)
Initializes the QSPI interface.
Definition: stm32h747i_eval_qspi.c:149
int32_t BSP_QSPI_DeInit(uint32_t Instance)
De-Initializes the QSPI interface.
Definition: stm32h747i_eval_qspi.c:234
int32_t BSP_QSPI_GetStatus(uint32_t Instance)
Reads current status of the QSPI memory. If WIP != 0 then return busy.
Definition: stm32h747i_eval_qspi.c:569
int32_t BSP_QSPI_EraseChip(uint32_t Instance)
Erases the entire QSPI memory.
Definition: stm32h747i_eval_qspi.c:529
int32_t BSP_QSPI_DisableMemoryMappedMode(uint32_t Instance)
Exit form memory-mapped mode Only 1 Instance can running MMP mode. And it will lock system at this mo...
Definition: stm32h747i_eval_qspi.c:674
int32_t BSP_QSPI_ConfigFlash(uint32_t Instance, BSP_QSPI_Interface_t Mode, BSP_QSPI_Transfer_t Rate)
Set Flash to desired Interface mode. And this instance becomes current instance. If current instance ...
Definition: stm32h747i_eval_qspi.c:755
int32_t BSP_QSPI_ReadID(uint32_t Instance, uint8_t *Id)
Get flash ID, 3 Byte Manufacturer ID, Memory type, Memory density.
Definition: stm32h747i_eval_qspi.c:725
int32_t BSP_QSPI_GetInfo(uint32_t Instance, BSP_QSPI_Info_t *pInfo)
Return the configuration of the QSPI memory.
Definition: stm32h747i_eval_qspi.c:605
BSP_QSPI_Erase_t
Definition: stm32h747i_eval_qspi.h:94
BSP_QSPI_Access_t
Definition: stm32h747i_eval_qspi.h:103
@ BSP_QSPI_ERASE_CHIP
Definition: stm32h747i_eval_qspi.h:98
@ BSP_QSPI_ERASE_64K
Definition: stm32h747i_eval_qspi.h:96
@ BSP_QSPI_ERASE_128K
Definition: stm32h747i_eval_qspi.h:97
@ BSP_QSPI_ERASE_8K
Definition: stm32h747i_eval_qspi.h:95
@ QSPI_ACCESS_INDIRECT
Definition: stm32h747i_eval_qspi.h:105
@ QSPI_ACCESS_MMP
Definition: stm32h747i_eval_qspi.h:106
@ QSPI_ACCESS_NONE
Definition: stm32h747i_eval_qspi.h:104
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
Definition: stm32h747i_eval_qspi.h:110
BSP_QSPI_Interface_t InterfaceMode
Definition: stm32h747i_eval_qspi.h:112
uint32_t DualFlashMode
Definition: stm32h747i_eval_qspi.h:114
BSP_QSPI_Access_t IsInitialized
Definition: stm32h747i_eval_qspi.h:111
BSP_QSPI_Transfer_t TransferRate
Definition: stm32h747i_eval_qspi.h:113
Definition: stm32h747i_eval_qspi.h:119
BSP_QSPI_Interface_t InterfaceMode
Definition: stm32h747i_eval_qspi.h:120
BSP_QSPI_Transfer_t TransferRate
Definition: stm32h747i_eval_qspi.h:121
BSP_QSPI_DualFlash_t DualFlashMode
Definition: stm32h747i_eval_qspi.h:122
Definition: stm32h747i_eval_qspi.h:126