RTEMS 6.1-rc1
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;
112
116#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
117typedef struct __NAND_HandleTypeDef
118#else
119typedef struct
120#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
121{
122 FMC_NAND_TypeDef *Instance;
132#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
133 void (* MspInitCallback)(struct __NAND_HandleTypeDef *hnand);
134 void (* MspDeInitCallback)(struct __NAND_HandleTypeDef *hnand);
135 void (* ItCallback)(struct __NAND_HandleTypeDef *hnand);
136#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
138
139#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
143typedef enum
144{
145 HAL_NAND_MSP_INIT_CB_ID = 0x00U,
146 HAL_NAND_MSP_DEINIT_CB_ID = 0x01U,
147 HAL_NAND_IT_CB_ID = 0x02U
148} HAL_NAND_CallbackIDTypeDef;
149
153typedef void (*pNAND_CallbackTypeDef)(NAND_HandleTypeDef *hnand);
154#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
155
160/* Exported constants --------------------------------------------------------*/
161/* Exported macro ------------------------------------------------------------*/
171#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
172#define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) do { \
173 (__HANDLE__)->State = HAL_NAND_STATE_RESET; \
174 (__HANDLE__)->MspInitCallback = NULL; \
175 (__HANDLE__)->MspDeInitCallback = NULL; \
176 } while(0)
177#else
178#define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NAND_STATE_RESET)
179#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
180
185/* Exported functions --------------------------------------------------------*/
194/* Initialization/de-initialization functions ********************************/
195HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingTypeDef *ComSpace_Timing,
196 FMC_NAND_PCC_TimingTypeDef *AttSpace_Timing);
197HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand);
198
199HAL_StatusTypeDef HAL_NAND_ConfigDevice(NAND_HandleTypeDef *hnand, NAND_DeviceConfigTypeDef *pDeviceConfig);
200
201HAL_StatusTypeDef HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID);
202
203void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand);
204void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand);
205void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand);
206void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand);
207
216/* IO operation functions ****************************************************/
217HAL_StatusTypeDef HAL_NAND_Reset(NAND_HandleTypeDef *hnand);
218
219HAL_StatusTypeDef HAL_NAND_Read_Page_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint8_t *pBuffer,
220 uint32_t NumPageToRead);
221HAL_StatusTypeDef HAL_NAND_Write_Page_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint8_t *pBuffer,
222 uint32_t NumPageToWrite);
223HAL_StatusTypeDef HAL_NAND_Read_SpareArea_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress,
224 uint8_t *pBuffer, uint32_t NumSpareAreaToRead);
225HAL_StatusTypeDef HAL_NAND_Write_SpareArea_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress,
226 uint8_t *pBuffer, uint32_t NumSpareAreaTowrite);
227
228HAL_StatusTypeDef HAL_NAND_Read_Page_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint16_t *pBuffer,
229 uint32_t NumPageToRead);
230HAL_StatusTypeDef HAL_NAND_Write_Page_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint16_t *pBuffer,
231 uint32_t NumPageToWrite);
232HAL_StatusTypeDef HAL_NAND_Read_SpareArea_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress,
233 uint16_t *pBuffer, uint32_t NumSpareAreaToRead);
234HAL_StatusTypeDef HAL_NAND_Write_SpareArea_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress,
235 uint16_t *pBuffer, uint32_t NumSpareAreaTowrite);
236
237HAL_StatusTypeDef HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress);
238
239uint32_t HAL_NAND_Address_Inc(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress);
240
241#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
242/* NAND callback registering/unregistering */
243HAL_StatusTypeDef HAL_NAND_RegisterCallback(NAND_HandleTypeDef *hnand, HAL_NAND_CallbackIDTypeDef CallbackId,
244 pNAND_CallbackTypeDef pCallback);
245HAL_StatusTypeDef HAL_NAND_UnRegisterCallback(NAND_HandleTypeDef *hnand, HAL_NAND_CallbackIDTypeDef CallbackId);
246#endif /* USE_HAL_NAND_REGISTER_CALLBACKS */
247
256/* NAND Control functions ****************************************************/
257HAL_StatusTypeDef HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand);
258HAL_StatusTypeDef HAL_NAND_ECC_Disable(NAND_HandleTypeDef *hnand);
259HAL_StatusTypeDef HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, uint32_t Timeout);
260
268/* NAND State functions *******************************************************/
269HAL_NAND_StateTypeDef HAL_NAND_GetState(NAND_HandleTypeDef *hnand);
270uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand);
279/* Private types -------------------------------------------------------------*/
280/* Private variables ---------------------------------------------------------*/
281/* Private constants ---------------------------------------------------------*/
286#define NAND_DEVICE 0x80000000UL
287#define NAND_WRITE_TIMEOUT 0x01000000UL
288
289#define CMD_AREA (1UL<<16U) /* A16 = CLE high */
290#define ADDR_AREA (1UL<<17U) /* A17 = ALE high */
291
292#define NAND_CMD_AREA_A ((uint8_t)0x00)
293#define NAND_CMD_AREA_B ((uint8_t)0x01)
294#define NAND_CMD_AREA_C ((uint8_t)0x50)
295#define NAND_CMD_AREA_TRUE1 ((uint8_t)0x30)
296
297#define NAND_CMD_WRITE0 ((uint8_t)0x80)
298#define NAND_CMD_WRITE_TRUE1 ((uint8_t)0x10)
299#define NAND_CMD_ERASE0 ((uint8_t)0x60)
300#define NAND_CMD_ERASE1 ((uint8_t)0xD0)
301#define NAND_CMD_READID ((uint8_t)0x90)
302#define NAND_CMD_STATUS ((uint8_t)0x70)
303#define NAND_CMD_LOCK_STATUS ((uint8_t)0x7A)
304#define NAND_CMD_RESET ((uint8_t)0xFF)
305
306/* NAND memory status */
307#define NAND_VALID_ADDRESS 0x00000100UL
308#define NAND_INVALID_ADDRESS 0x00000200UL
309#define NAND_TIMEOUT_ERROR 0x00000400UL
310#define NAND_BUSY 0x00000000UL
311#define NAND_ERROR 0x00000001UL
312#define NAND_READY 0x00000040UL
317/* Private macros ------------------------------------------------------------*/
329#define ARRAY_ADDRESS(__ADDRESS__ , __HANDLE__) ((__ADDRESS__)->Page + \
330 (((__ADDRESS__)->Block + \
331 (((__ADDRESS__)->Plane) * \
332 ((__HANDLE__)->Config.PlaneSize))) * \
333 ((__HANDLE__)->Config.BlockSize)))
334
340#define COLUMN_ADDRESS( __HANDLE__) ((__HANDLE__)->Config.PageSize)
341
347#define ADDR_1ST_CYCLE(__ADDRESS__) (uint8_t)(__ADDRESS__) /* 1st addressing cycle */
348#define ADDR_2ND_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 8) /* 2nd addressing cycle */
349#define ADDR_3RD_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 16) /* 3rd addressing cycle */
350#define ADDR_4TH_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 24) /* 4th addressing cycle */
351
357#define COLUMN_1ST_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) & 0xFFU) /* 1st Column addressing cycle */
358#define COLUMN_2ND_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 8) /* 2nd Column addressing cycle */
359
377#ifdef __cplusplus
378}
379#endif
380
381#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:121
FMC_NAND_InitTypeDef Init
Definition: stm32h7xx_hal_nand.h:124
HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_nand.h:126
NAND_DeviceConfigTypeDef Config
Definition: stm32h7xx_hal_nand.h:130
__IO HAL_NAND_StateTypeDef State
Definition: stm32h7xx_hal_nand.h:128
NAND Memory electronic signature Structure definition.
Definition: stm32h7xx_hal_nand.h:61