RTEMS 6.1-rc6
Loading...
Searching...
No Matches
stm32h7xx_hal_nand.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_HAL_NAND_H
21#define STM32H7xx_HAL_NAND_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28/* Includes ------------------------------------------------------------------*/
29#include "stm32h7xx_ll_fmc.h"
30
39/* Exported typedef ----------------------------------------------------------*/
40/* Exported types ------------------------------------------------------------*/
49typedef enum
50{
56
60typedef struct
61{
62 /*<! NAND memory electronic signature maker and device IDs */
63
64 uint8_t Maker_Id;
65
66 uint8_t Device_Id;
67
68 uint8_t Third_Id;
69
70 uint8_t Fourth_Id;
72
76typedef struct
77{
78 uint16_t Page;
80 uint16_t Plane;
82 uint16_t Block;
85
89typedef struct
90{
91 uint32_t PageSize;
94 uint32_t SpareAreaSize;
97 uint32_t BlockSize;
99 uint32_t BlockNbr;
101 uint32_t PlaneNbr;
103 uint32_t PlaneSize;
105 FunctionalState ExtraCommandEnable;
111
115#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
116typedef struct __NAND_HandleTypeDef
117#else
118typedef struct
119#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
120{
121 FMC_NAND_TypeDef *Instance;
131#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
132 void (* MspInitCallback)(struct __NAND_HandleTypeDef *hnand);
133 void (* MspDeInitCallback)(struct __NAND_HandleTypeDef *hnand);
134 void (* ItCallback)(struct __NAND_HandleTypeDef *hnand);
135#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
137
138#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
142typedef enum
143{
144 HAL_NAND_MSP_INIT_CB_ID = 0x00U,
145 HAL_NAND_MSP_DEINIT_CB_ID = 0x01U,
146 HAL_NAND_IT_CB_ID = 0x02U
147} HAL_NAND_CallbackIDTypeDef;
148
152typedef void (*pNAND_CallbackTypeDef)(NAND_HandleTypeDef *hnand);
153#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
154
159/* Exported constants --------------------------------------------------------*/
160/* Exported macro ------------------------------------------------------------*/
170#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
171#define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) do { \
172 (__HANDLE__)->State = HAL_NAND_STATE_RESET; \
173 (__HANDLE__)->MspInitCallback = NULL; \
174 (__HANDLE__)->MspDeInitCallback = NULL; \
175 } while(0)
176#else
177#define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NAND_STATE_RESET)
178#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
179
184/* Exported functions --------------------------------------------------------*/
193/* Initialization/de-initialization functions ********************************/
194HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingTypeDef *ComSpace_Timing,
195 FMC_NAND_PCC_TimingTypeDef *AttSpace_Timing);
196HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand);
197
198HAL_StatusTypeDef HAL_NAND_ConfigDevice(NAND_HandleTypeDef *hnand, NAND_DeviceConfigTypeDef *pDeviceConfig);
199
200HAL_StatusTypeDef HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID);
201
202void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand);
203void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand);
204void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand);
205void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand);
206
215/* IO operation functions ****************************************************/
216HAL_StatusTypeDef HAL_NAND_Reset(NAND_HandleTypeDef *hnand);
217
218HAL_StatusTypeDef HAL_NAND_Read_Page_8b(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress,
219 uint8_t *pBuffer, uint32_t NumPageToRead);
220HAL_StatusTypeDef HAL_NAND_Write_Page_8b(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress,
221 const uint8_t *pBuffer, uint32_t NumPageToWrite);
222HAL_StatusTypeDef HAL_NAND_Read_SpareArea_8b(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress,
223 uint8_t *pBuffer, uint32_t NumSpareAreaToRead);
224HAL_StatusTypeDef HAL_NAND_Write_SpareArea_8b(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress,
225 const uint8_t *pBuffer, uint32_t NumSpareAreaTowrite);
226
227HAL_StatusTypeDef HAL_NAND_Read_Page_16b(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress,
228 uint16_t *pBuffer, uint32_t NumPageToRead);
229HAL_StatusTypeDef HAL_NAND_Write_Page_16b(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress,
230 const uint16_t *pBuffer, uint32_t NumPageToWrite);
231HAL_StatusTypeDef HAL_NAND_Read_SpareArea_16b(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress,
232 uint16_t *pBuffer, uint32_t NumSpareAreaToRead);
233HAL_StatusTypeDef HAL_NAND_Write_SpareArea_16b(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress,
234 const uint16_t *pBuffer, uint32_t NumSpareAreaTowrite);
235
236HAL_StatusTypeDef HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, const NAND_AddressTypeDef *pAddress);
237
238uint32_t HAL_NAND_Address_Inc(const NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress);
239
240#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
241/* NAND callback registering/unregistering */
242HAL_StatusTypeDef HAL_NAND_RegisterCallback(NAND_HandleTypeDef *hnand, HAL_NAND_CallbackIDTypeDef CallbackId,
243 pNAND_CallbackTypeDef pCallback);
244HAL_StatusTypeDef HAL_NAND_UnRegisterCallback(NAND_HandleTypeDef *hnand, HAL_NAND_CallbackIDTypeDef CallbackId);
245#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
246
255/* NAND Control functions ****************************************************/
256HAL_StatusTypeDef HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand);
257HAL_StatusTypeDef HAL_NAND_ECC_Disable(NAND_HandleTypeDef *hnand);
258HAL_StatusTypeDef HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, uint32_t Timeout);
259
267/* NAND State functions *******************************************************/
268HAL_NAND_StateTypeDef HAL_NAND_GetState(const NAND_HandleTypeDef *hnand);
269uint32_t HAL_NAND_Read_Status(const NAND_HandleTypeDef *hnand);
278/* Private types -------------------------------------------------------------*/
279/* Private variables ---------------------------------------------------------*/
280/* Private constants ---------------------------------------------------------*/
285#define NAND_DEVICE 0x80000000UL
286#define NAND_WRITE_TIMEOUT 0x01000000UL
287
288#define CMD_AREA (1UL<<16U) /* A16 = CLE high */
289#define ADDR_AREA (1UL<<17U) /* A17 = ALE high */
290
291#define NAND_CMD_AREA_A ((uint8_t)0x00)
292#define NAND_CMD_AREA_B ((uint8_t)0x01)
293#define NAND_CMD_AREA_C ((uint8_t)0x50)
294#define NAND_CMD_AREA_TRUE1 ((uint8_t)0x30)
295
296#define NAND_CMD_WRITE0 ((uint8_t)0x80)
297#define NAND_CMD_WRITE_TRUE1 ((uint8_t)0x10)
298#define NAND_CMD_ERASE0 ((uint8_t)0x60)
299#define NAND_CMD_ERASE1 ((uint8_t)0xD0)
300#define NAND_CMD_READID ((uint8_t)0x90)
301#define NAND_CMD_STATUS ((uint8_t)0x70)
302#define NAND_CMD_LOCK_STATUS ((uint8_t)0x7A)
303#define NAND_CMD_RESET ((uint8_t)0xFF)
304
305/* NAND memory status */
306#define NAND_VALID_ADDRESS 0x00000100UL
307#define NAND_INVALID_ADDRESS 0x00000200UL
308#define NAND_TIMEOUT_ERROR 0x00000400UL
309#define NAND_BUSY 0x00000000UL
310#define NAND_ERROR 0x00000001UL
311#define NAND_READY 0x00000040UL
316/* Private macros ------------------------------------------------------------*/
328#define ARRAY_ADDRESS(__ADDRESS__ , __HANDLE__) ((__ADDRESS__)->Page + \
329 (((__ADDRESS__)->Block + \
330 (((__ADDRESS__)->Plane) * \
331 ((__HANDLE__)->Config.PlaneSize))) * \
332 ((__HANDLE__)->Config.BlockSize)))
333
339#define COLUMN_ADDRESS( __HANDLE__) ((__HANDLE__)->Config.PageSize)
340
346#define ADDR_1ST_CYCLE(__ADDRESS__) (uint8_t)(__ADDRESS__) /* 1st addressing cycle */
347#define ADDR_2ND_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 8) /* 2nd addressing cycle */
348#define ADDR_3RD_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 16) /* 3rd addressing cycle */
349#define ADDR_4TH_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 24) /* 4th addressing cycle */
350
356#define COLUMN_1ST_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) & 0xFFU) /* 1st Column addressing cycle */
357#define COLUMN_2ND_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 8) /* 2nd Column addressing cycle */
358
376#ifdef __cplusplus
377}
378#endif
379
380#endif /* STM32H7xx_HAL_NAND_H */
#define __IO
Definition: core_cm4.h:239
HAL_NAND_StateTypeDef
HAL NAND State structures definition.
Definition: stm32h7xx_hal_nand.h:50
@ HAL_NAND_STATE_BUSY
Definition: stm32h7xx_hal_nand.h:53
@ HAL_NAND_STATE_RESET
Definition: stm32h7xx_hal_nand.h:51
@ HAL_NAND_STATE_READY
Definition: stm32h7xx_hal_nand.h:52
@ HAL_NAND_STATE_ERROR
Definition: stm32h7xx_hal_nand.h:54
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of FMC HAL module.
FMC NAND Configuration Structure definition.
Definition: stm32h7xx_ll_fmc.h:299
FMC NAND Timing parameters structure definition.
Definition: stm32h7xx_ll_fmc.h:328
NAND Memory address Structure definition.
Definition: stm32h7xx_hal_nand.h:77
uint16_t Plane
Definition: stm32h7xx_hal_nand.h:80
uint16_t Page
Definition: stm32h7xx_hal_nand.h:78
uint16_t Block
Definition: stm32h7xx_hal_nand.h:82
NAND Memory info Structure definition.
Definition: stm32h7xx_hal_nand.h:90
uint32_t BlockNbr
Definition: stm32h7xx_hal_nand.h:99
FunctionalState ExtraCommandEnable
Definition: stm32h7xx_hal_nand.h:105
uint32_t BlockSize
Definition: stm32h7xx_hal_nand.h:97
uint32_t SpareAreaSize
Definition: stm32h7xx_hal_nand.h:94
uint32_t PageSize
Definition: stm32h7xx_hal_nand.h:91
uint32_t PlaneNbr
Definition: stm32h7xx_hal_nand.h:101
uint32_t PlaneSize
Definition: stm32h7xx_hal_nand.h:103
NAND handle Structure definition.
Definition: stm32h7xx_hal_nand.h:120
FMC_NAND_InitTypeDef Init
Definition: stm32h7xx_hal_nand.h:123
FMC_NAND_TypeDef * Instance
Definition: stm32h7xx_hal_nand.h:121
HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_nand.h:125
NAND_DeviceConfigTypeDef Config
Definition: stm32h7xx_hal_nand.h:129
__IO HAL_NAND_StateTypeDef State
Definition: stm32h7xx_hal_nand.h:127
NAND Memory electronic signature Structure definition.
Definition: stm32h7xx_hal_nand.h:61