STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_hal_nor.h
Go to the documentation of this file.
1 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __STM32L4xx_HAL_NOR_H
22 #define __STM32L4xx_HAL_NOR_H
23 
24 #ifdef __cplusplus
25  extern "C" {
26 #endif
27 
28 #if defined(FMC_BANK1)
29 
30 /* Includes ------------------------------------------------------------------*/
31 #include "stm32l4xx_ll_fmc.h"
32 
33 
42 /* Exported typedef ----------------------------------------------------------*/
50 typedef enum
51 {
52  HAL_NOR_STATE_RESET = 0x00U,
53  HAL_NOR_STATE_READY = 0x01U,
54  HAL_NOR_STATE_BUSY = 0x02U,
55  HAL_NOR_STATE_ERROR = 0x03U,
56  HAL_NOR_STATE_PROTECTED = 0x04U
57 }HAL_NOR_StateTypeDef;
58 
62 typedef enum
63 {
69 
73 typedef struct
74 {
75  uint16_t Manufacturer_Code;
77  uint16_t Device_Code1;
78 
79  uint16_t Device_Code2;
80 
81  uint16_t Device_Code3;
86 
90 typedef struct
91 {
96  uint16_t CFI_1;
97 
98  uint16_t CFI_2;
99 
100  uint16_t CFI_3;
101 
102  uint16_t CFI_4;
104 
108 typedef struct
109 {
110  FMC_NORSRAM_TypeDef *Instance;
112  FMC_NORSRAM_EXTENDED_TypeDef *Extended;
118  __IO HAL_NOR_StateTypeDef State;
124 /* Exported constants --------------------------------------------------------*/
125 /* Exported macro ------------------------------------------------------------*/
133 #define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NOR_STATE_RESET)
134 
138 /* Exported functions --------------------------------------------------------*/
147 /* Initialization/de-initialization functions ********************************/
148 HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming);
149 HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor);
152 void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout);
161 /* I/O operation functions ***************************************************/
162 HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID);
163 HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor);
164 HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData);
165 HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData);
166 
167 HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize);
168 HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize);
169 
170 HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address);
171 HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address);
172 HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI);
181 /* NOR Control functions *****************************************************/
182 HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor);
183 HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor);
192 /* NOR State functions ********************************************************/
193 HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor);
194 HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout);
203 /* Private types -------------------------------------------------------------*/
204 /* Private variables ---------------------------------------------------------*/
205 /* Private constants ---------------------------------------------------------*/
209 /* NOR device IDs addresses */
210 #define MC_ADDRESS ((uint16_t)0x0000U)
211 #define DEVICE_CODE1_ADDR ((uint16_t)0x0001U)
212 #define DEVICE_CODE2_ADDR ((uint16_t)0x000EU)
213 #define DEVICE_CODE3_ADDR ((uint16_t)0x000FU)
214 
215 /* NOR CFI IDs addresses */
216 #define CFI1_ADDRESS ((uint16_t)0x61U)
217 #define CFI2_ADDRESS ((uint16_t)0x62U)
218 #define CFI3_ADDRESS ((uint16_t)0x63U)
219 #define CFI4_ADDRESS ((uint16_t)0x64U)
220 
221 /* NOR operation wait timeout */
222 #define NOR_TMEOUT ((uint16_t)0xFFFFU)
223 
224 /* NOR memory data width */
225 #define NOR_MEMORY_8B ((uint8_t)0x0U)
226 #define NOR_MEMORY_16B ((uint8_t)0x1U)
227 
228 /* NOR memory device read/write start address */
229 #define NOR_MEMORY_ADRESS1 ((uint32_t)0x60000000U)
230 #define NOR_MEMORY_ADRESS2 ((uint32_t)0x64000000U)
231 #define NOR_MEMORY_ADRESS3 ((uint32_t)0x68000000U)
232 #define NOR_MEMORY_ADRESS4 ((uint32_t)0x6C000000U)
233 
237 /* Private macros ------------------------------------------------------------*/
248 #define NOR_ADDR_SHIFT(__NOR_ADDRESS, __NOR_MEMORY_WIDTH_, __ADDRESS__) \
249  ((uint32_t)(((__NOR_MEMORY_WIDTH_) == NOR_MEMORY_16B)? \
250  ((uint32_t)((__NOR_ADDRESS) + (2 * (__ADDRESS__)))): \
251  ((uint32_t)((__NOR_ADDRESS) + (__ADDRESS__)))))
252 
259 #define NOR_WRITE(__ADDRESS__, __DATA__) do{ \
260  (*(__IO uint16_t *)((uint32_t)(__ADDRESS__)) = (__DATA__)); \
261  __DSB(); \
262  } while(0)
263 
276 #endif /* FMC_BANK1 */
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 #endif /* __STM32L4xx_HAL_NOR_H */
283 
284 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor)
Perform NOR memory De-Initialization sequence.
FMC_NORSRAM_TypeDef * Instance
void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout)
NOR MSP Wait for Ready/Busy signal.
FMC NOR CFI typedef.
HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address)
Erase the specified block of the NOR memory.
HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout)
Return the NOR operation status.
HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize)
Writes a half-word buffer to the NOR memory. This function must be used only with S29GL128P NOR memor...
uint16_t Device_Code1
HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming)
Perform the NOR memory Initialization sequence.
HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize)
Read a half-word buffer from the NOR memory.
uint16_t Manufacturer_Code
FMC_NORSRAM_EXTENDED_TypeDef * Extended
FMC NORSRAM Configuration Structure definition.
HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor)
Enable dynamically NOR write operation.
HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID)
Read NOR flash IDs.
HAL_NOR_StatusTypeDef
FMC NOR Status typedef.
FMC_NORSRAM_InitTypeDef Init
HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address)
Erase the entire NOR chip.
FMC NORSRAM Timing parameters structure definition.
HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor)
Return the NOR memory to Read mode.
HAL_LockTypeDef
HAL Lock structures definition.
HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)
Program data to NOR memory.
FMC NOR ID typedef.
Header file of FMC HAL module.
HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor)
Disable dynamically NOR write operation.
HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI)
Read NOR flash CFI IDs.
uint16_t Device_Code3
void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor)
DeInitialize the NOR MSP.
HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor)
Return the NOR controller state.
uint16_t Device_Code2
void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor)
Initialize the NOR MSP.
__IO HAL_NOR_StateTypeDef State
HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)
Read data from NOR memory.
HAL_LockTypeDef Lock
NOR handle Structure definition.