Subversion Repositories LedShow

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 9
Line 4... Line 4...
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   Header file of NAND HAL module.
5
  * @brief   Header file of NAND HAL module.
6
  ******************************************************************************
6
  ******************************************************************************
7
  * @attention
7
  * @attention
8
  *
8
  *
9
  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
9
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
-
 
10
  * All rights reserved.</center></h2>
10
  *
11
  *
11
  * Redistribution and use in source and binary forms, with or without modification,
12
  * This software component is licensed by ST under BSD 3-Clause license,
12
  * are permitted provided that the following conditions are met:
13
  * the "License"; You may not use this file except in compliance with the
13
  *   1. Redistributions of source code must retain the above copyright notice,
-
 
14
  *      this list of conditions and the following disclaimer.
14
  * License. You may obtain a copy of the License at:
15
  *   2. Redistributions in binary form must reproduce the above copyright notice,
-
 
16
  *      this list of conditions and the following disclaimer in the documentation
-
 
17
  *      and/or other materials provided with the distribution.
15
  *                       opensource.org/licenses/BSD-3-Clause
18
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-
 
19
  *      may be used to endorse or promote products derived from this software
-
 
20
  *      without specific prior written permission.
-
 
21
  *
-
 
22
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
 
23
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
24
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-
 
25
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-
 
26
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-
 
27
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-
 
28
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-
 
29
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-
 
30
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
 
31
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
32
  *
16
  *
33
  ******************************************************************************
17
  ******************************************************************************
34
  */
18
  */
35
 
19
 
36
/* Define to prevent recursive inclusion -------------------------------------*/
20
/* Define to prevent recursive inclusion -------------------------------------*/
37
#ifndef __STM32F1xx_HAL_NAND_H
21
#ifndef STM32F1xx_HAL_NAND_H
38
#define __STM32F1xx_HAL_NAND_H
22
#define STM32F1xx_HAL_NAND_H
39
 
23
 
40
#ifdef __cplusplus
24
#ifdef __cplusplus
41
 extern "C" {
25
extern "C" {
42
#endif
26
#endif
43
 
27
 
-
 
28
#if defined(FSMC_BANK3)
-
 
29
 
44
/* Includes ------------------------------------------------------------------*/
30
/* Includes ------------------------------------------------------------------*/
45
#include "stm32f1xx_ll_fsmc.h"
31
#include "stm32f1xx_ll_fsmc.h"
46
 
32
 
47
/** @addtogroup STM32F1xx_HAL_Driver
33
/** @addtogroup STM32F1xx_HAL_Driver
48
  * @{
34
  * @{
49
  */
35
  */
50
 
36
 
51
#if defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)
-
 
52
/** @addtogroup NAND
37
/** @addtogroup NAND
53
  * @{
38
  * @{
54
  */
39
  */
55
 
-
 
56
 
40
 
57
/* Exported typedef ----------------------------------------------------------*/
41
/* Exported typedef ----------------------------------------------------------*/
58
/* Exported types ------------------------------------------------------------*/
42
/* Exported types ------------------------------------------------------------*/
59
/** @defgroup NAND_Exported_Types NAND Exported Types
43
/** @defgroup NAND_Exported_Types NAND Exported Types
60
  * @{
44
  * @{
61
  */
45
  */
62
 
46
 
63
/**
47
/**
64
  * @brief  HAL NAND State structures definition
48
  * @brief  HAL NAND State structures definition
65
  */
49
  */
66
typedef enum
50
typedef enum
67
{
51
{
68
  HAL_NAND_STATE_RESET     = 0x00U,  /*!< NAND not yet initialized or disabled */
52
  HAL_NAND_STATE_RESET     = 0x00U,  /*!< NAND not yet initialized or disabled */
69
  HAL_NAND_STATE_READY     = 0x01U,  /*!< NAND initialized and ready for use   */
53
  HAL_NAND_STATE_READY     = 0x01U,  /*!< NAND initialized and ready for use   */
70
  HAL_NAND_STATE_BUSY      = 0x02U,  /*!< NAND internal process is ongoing     */
54
  HAL_NAND_STATE_BUSY      = 0x02U,  /*!< NAND internal process is ongoing     */
71
  HAL_NAND_STATE_ERROR     = 0x03U   /*!< NAND error state                     */
55
  HAL_NAND_STATE_ERROR     = 0x03U   /*!< NAND error state                     */
72
}HAL_NAND_StateTypeDef;
56
} HAL_NAND_StateTypeDef;
73
   
57
 
74
/**
58
/**
75
  * @brief  NAND Memory electronic signature Structure definition
59
  * @brief  NAND Memory electronic signature Structure definition
76
  */
60
  */
77
typedef struct
61
typedef struct
78
{
62
{
79
  /*<! NAND memory electronic signature maker and device IDs */
63
  /*<! NAND memory electronic signature maker and device IDs */
80
 
64
 
81
  uint8_t Maker_Id;
65
  uint8_t Maker_Id;
82
 
66
 
83
  uint8_t Device_Id;
67
  uint8_t Device_Id;
84
 
68
 
85
  uint8_t Third_Id;
69
  uint8_t Third_Id;
86
 
70
 
87
  uint8_t Fourth_Id;
71
  uint8_t Fourth_Id;
88
}NAND_IDTypeDef;
72
} NAND_IDTypeDef;
89
 
73
 
90
/**
74
/**
91
  * @brief  NAND Memory address Structure definition
75
  * @brief  NAND Memory address Structure definition
92
  */
76
  */
93
typedef struct
77
typedef struct
94
{
78
{
95
  uint16_t Page;   /*!< NAND memory Page address    */
79
  uint16_t Page;   /*!< NAND memory Page address  */
96
 
80
 
97
  uint16_t Plane;   /*!< NAND memory Plane address  */
81
  uint16_t Plane;   /*!< NAND memory Zone address  */
98
 
82
 
99
  uint16_t Block;  /*!< NAND memory Block address   */
83
  uint16_t Block;  /*!< NAND memory Block address */
100
 
84
 
101
}NAND_AddressTypeDef;
85
} NAND_AddressTypeDef;
102
 
86
 
103
/**
87
/**
104
  * @brief  NAND Memory info Structure definition
88
  * @brief  NAND Memory info Structure definition
105
  */
89
  */
106
typedef struct
90
typedef struct
107
{
91
{
108
  uint32_t        PageSize;              /*!< NAND memory page (without spare area) size measured in bytes
92
  uint32_t        PageSize;              /*!< NAND memory page (without spare area) size measured in bytes
-
 
93
                                              for 8 bits addressing or words for 16 bits addressing             */
-
 
94
 
-
 
95
  uint32_t        SpareAreaSize;         /*!< NAND memory spare area size measured in bytes
109
                                              for 8 bits adressing or words for 16 bits addressing             */
96
                                              for 8 bits addressing or words for 16 bits addressing             */
110
 
97
 
111
  uint32_t        SpareAreaSize;         /*!< NAND memory spare area size measured in bytes
-
 
112
                                              for 8 bits adressing or words for 16 bits addressing             */
-
 
113
 
-
 
114
  uint32_t        BlockSize;             /*!< NAND memory block size measured in number of pages               */
98
  uint32_t        BlockSize;             /*!< NAND memory block size measured in number of pages               */
115
 
99
 
116
  uint32_t        BlockNbr;              /*!< NAND memory number of total blocks                               */
100
  uint32_t        BlockNbr;              /*!< NAND memory number of total blocks                               */
117
     
101
 
118
  uint32_t        PlaneNbr;              /*!< NAND memory number of planes                                     */
102
  uint32_t        PlaneNbr;              /*!< NAND memory number of planes                                     */
119
 
103
 
120
  uint32_t        PlaneSize;             /*!< NAND memory plane size measured in number of blocks              */
104
  uint32_t        PlaneSize;             /*!< NAND memory zone size measured in number of blocks               */
121
 
105
 
122
  FunctionalState ExtraCommandEnable;    /*!< NAND extra command needed for Page reading mode. This
106
  FunctionalState ExtraCommandEnable;    /*!< NAND extra command needed for Page reading mode. This
123
                                              parameter is mandatory for some NAND parts after the read
107
                                              parameter is mandatory for some NAND parts after the read
124
                                              command (NAND_CMD_AREA_TRUE1) and before DATA reading sequence.
108
                                              command (NAND_CMD_AREA_TRUE1) and before DATA reading sequence.
125
                                              Example: Toshiba THTH58BYG3S0HBAI6.
109
                                              Example: Toshiba THTH58BYG3S0HBAI6.
126
                                              This parameter could be ENABLE or DISABLE
110
                                              This parameter could be ENABLE or DISABLE
127
                                              Please check the Read Mode sequnece in the NAND device datasheet */
111
                                              Please check the Read Mode sequnece in the NAND device datasheet */
128
}NAND_DeviceConfigTypeDef;
112
} NAND_DeviceConfigTypeDef;
129
 
113
 
130
/**
114
/**
131
  * @brief  NAND handle Structure definition
115
  * @brief  NAND handle Structure definition
132
  */  
116
  */
-
 
117
#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
-
 
118
typedef struct __NAND_HandleTypeDef
-
 
119
#else
133
typedef struct
120
typedef struct
-
 
121
#endif /* USE_HAL_NAND_REGISTER_CALLBACKS  */
134
{
122
{
135
  FSMC_NAND_TypeDef              *Instance;  /*!< Register base address                                 */
123
  FSMC_NAND_TypeDef               *Instance;  /*!< Register base address                                 */
136
 
124
 
137
  FSMC_NAND_InitTypeDef          Init;       /*!< NAND device control configuration parameters          */
125
  FSMC_NAND_InitTypeDef           Init;       /*!< NAND device control configuration parameters          */
138
 
126
 
139
  HAL_LockTypeDef                Lock;       /*!< NAND locking object                                   */
127
  HAL_LockTypeDef                Lock;       /*!< NAND locking object                                   */
140
 
128
 
141
  __IO HAL_NAND_StateTypeDef     State;      /*!< NAND device access state                              */
129
  __IO HAL_NAND_StateTypeDef     State;      /*!< NAND device access state                              */
142
 
130
 
143
  NAND_DeviceConfigTypeDef       Config;     /*!< NAND phusical characteristic information structure    */
131
  NAND_DeviceConfigTypeDef       Config;     /*!< NAND phusical characteristic information structure    */
144
 
132
 
-
 
133
#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
-
 
134
  void (* MspInitCallback)(struct __NAND_HandleTypeDef *hnand);               /*!< NAND Msp Init callback              */
-
 
135
  void (* MspDeInitCallback)(struct __NAND_HandleTypeDef *hnand);             /*!< NAND Msp DeInit callback            */
-
 
136
  void (* ItCallback)(struct __NAND_HandleTypeDef *hnand);                    /*!< NAND IT callback                    */
-
 
137
#endif
145
}NAND_HandleTypeDef;
138
} NAND_HandleTypeDef;
-
 
139
 
-
 
140
#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
-
 
141
/**
-
 
142
  * @brief  HAL NAND Callback ID enumeration definition
-
 
143
  */
-
 
144
typedef enum
-
 
145
{
-
 
146
  HAL_NAND_MSP_INIT_CB_ID       = 0x00U,  /*!< NAND MspInit Callback ID          */
-
 
147
  HAL_NAND_MSP_DEINIT_CB_ID     = 0x01U,  /*!< NAND MspDeInit Callback ID        */
-
 
148
  HAL_NAND_IT_CB_ID             = 0x02U   /*!< NAND IT Callback ID               */
-
 
149
} HAL_NAND_CallbackIDTypeDef;
-
 
150
 
-
 
151
/**
-
 
152
  * @brief  HAL NAND Callback pointer definition
-
 
153
  */
-
 
154
typedef void (*pNAND_CallbackTypeDef)(NAND_HandleTypeDef *hnand);
-
 
155
#endif
146
 
156
 
147
/**
157
/**
148
  * @}
158
  * @}
149
  */
159
  */
150
 
160
 
151
/* Exported constants --------------------------------------------------------*/
161
/* Exported constants --------------------------------------------------------*/
152
/* Exported macros -----------------------------------------------------------*/
162
/* Exported macro ------------------------------------------------------------*/
153
/** @defgroup NAND_Exported_Macros NAND Exported Macros
163
/** @defgroup NAND_Exported_Macros NAND Exported Macros
154
  * @{
164
  * @{
155
  */
165
  */
156
 
166
 
157
/** @brief Reset NAND handle state
167
/** @brief Reset NAND handle state
158
  * @param  __HANDLE__: specifies the NAND handle.
168
  * @param  __HANDLE__ specifies the NAND handle.
159
  * @retval None
169
  * @retval None
160
  */
170
  */
-
 
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
161
#define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NAND_STATE_RESET)
178
#define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NAND_STATE_RESET)
-
 
179
#endif
162
 
180
 
163
/**
181
/**
164
  * @}
182
  * @}
165
  */
183
  */
166
 
184
 
167
/* Exported functions --------------------------------------------------------*/
185
/* Exported functions --------------------------------------------------------*/
168
/** @addtogroup NAND_Exported_Functions NAND Exported Functions
186
/** @addtogroup NAND_Exported_Functions NAND Exported Functions
169
  * @{
187
  * @{
170
  */
188
  */
171
   
189
 
172
/** @addtogroup NAND_Exported_Functions_Group1 Initialization and de-initialization functions
190
/** @addtogroup NAND_Exported_Functions_Group1 Initialization and de-initialization functions
173
  * @{
191
  * @{
174
  */
192
  */
175
 
193
 
176
/* Initialization/de-initialization functions  ********************************/
194
/* Initialization/de-initialization functions  ********************************/
177
HAL_StatusTypeDef   HAL_NAND_Init(NAND_HandleTypeDef *hnand, FSMC_NAND_PCC_TimingTypeDef *ComSpace_Timing, FSMC_NAND_PCC_TimingTypeDef *AttSpace_Timing);
195
HAL_StatusTypeDef  HAL_NAND_Init(NAND_HandleTypeDef *hnand, FSMC_NAND_PCC_TimingTypeDef *ComSpace_Timing,
-
 
196
                                 FSMC_NAND_PCC_TimingTypeDef *AttSpace_Timing);
178
HAL_StatusTypeDef   HAL_NAND_DeInit(NAND_HandleTypeDef *hnand);
197
HAL_StatusTypeDef  HAL_NAND_DeInit(NAND_HandleTypeDef *hnand);
179
 
198
 
180
HAL_StatusTypeDef  HAL_NAND_ConfigDevice(NAND_HandleTypeDef *hnand, NAND_DeviceConfigTypeDef *pDeviceConfig);
199
HAL_StatusTypeDef  HAL_NAND_ConfigDevice(NAND_HandleTypeDef *hnand, NAND_DeviceConfigTypeDef *pDeviceConfig);
181
 
200
 
182
HAL_StatusTypeDef  HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID);
201
HAL_StatusTypeDef  HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID);
183
 
202
 
Line 187... Line 206...
187
void               HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand);
206
void               HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand);
188
 
207
 
189
/**
208
/**
190
  * @}
209
  * @}
191
  */
210
  */
192
 
211
 
193
/** @addtogroup NAND_Exported_Functions_Group2 Input and Output functions
212
/** @addtogroup NAND_Exported_Functions_Group2 Input and Output functions
194
  * @{
213
  * @{
195
  */
214
  */
196
 
215
 
197
/* IO operation functions  ****************************************************/
216
/* IO operation functions  ****************************************************/
198
 
-
 
199
HAL_StatusTypeDef  HAL_NAND_Reset(NAND_HandleTypeDef *hnand);
217
HAL_StatusTypeDef  HAL_NAND_Reset(NAND_HandleTypeDef *hnand);
200
 
218
 
201
HAL_StatusTypeDef  HAL_NAND_Read_Page_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint8_t *pBuffer, uint32_t NumPageToRead);
219
HAL_StatusTypeDef  HAL_NAND_Read_Page_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint8_t *pBuffer,
-
 
220
                                         uint32_t NumPageToRead);
202
HAL_StatusTypeDef  HAL_NAND_Write_Page_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint8_t *pBuffer, uint32_t NumPageToWrite);
221
HAL_StatusTypeDef  HAL_NAND_Write_Page_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint8_t *pBuffer,
-
 
222
                                          uint32_t NumPageToWrite);
203
HAL_StatusTypeDef  HAL_NAND_Read_SpareArea_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint8_t *pBuffer, uint32_t NumSpareAreaToRead);
223
HAL_StatusTypeDef  HAL_NAND_Read_SpareArea_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress,
-
 
224
                                              uint8_t *pBuffer, uint32_t NumSpareAreaToRead);
204
HAL_StatusTypeDef  HAL_NAND_Write_SpareArea_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint8_t *pBuffer, uint32_t NumSpareAreaTowrite);
225
HAL_StatusTypeDef  HAL_NAND_Write_SpareArea_8b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress,
-
 
226
                                               uint8_t *pBuffer, uint32_t NumSpareAreaTowrite);
205
 
227
 
206
HAL_StatusTypeDef  HAL_NAND_Read_Page_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint16_t *pBuffer, uint32_t NumPageToRead);
228
HAL_StatusTypeDef  HAL_NAND_Read_Page_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint16_t *pBuffer,
-
 
229
                                          uint32_t NumPageToRead);
207
HAL_StatusTypeDef  HAL_NAND_Write_Page_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint16_t *pBuffer, uint32_t NumPageToWrite);
230
HAL_StatusTypeDef  HAL_NAND_Write_Page_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint16_t *pBuffer,
-
 
231
                                           uint32_t NumPageToWrite);
208
HAL_StatusTypeDef  HAL_NAND_Read_SpareArea_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint16_t *pBuffer, uint32_t NumSpareAreaToRead);
232
HAL_StatusTypeDef  HAL_NAND_Read_SpareArea_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress,
-
 
233
                                               uint16_t *pBuffer, uint32_t NumSpareAreaToRead);
209
HAL_StatusTypeDef  HAL_NAND_Write_SpareArea_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress, uint16_t *pBuffer, uint32_t NumSpareAreaTowrite);
234
HAL_StatusTypeDef  HAL_NAND_Write_SpareArea_16b(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress,
-
 
235
                                                uint16_t *pBuffer, uint32_t NumSpareAreaTowrite);
210
 
236
 
211
HAL_StatusTypeDef  HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress);
237
HAL_StatusTypeDef  HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress);
212
uint32_t           HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand);
-
 
-
 
238
 
213
uint32_t           HAL_NAND_Address_Inc(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress);
239
uint32_t           HAL_NAND_Address_Inc(NAND_HandleTypeDef *hnand, NAND_AddressTypeDef *pAddress);
214
 
240
 
-
 
241
#if (USE_HAL_NAND_REGISTER_CALLBACKS == 1)
-
 
242
/* NAND callback registering/unregistering */
-
 
243
HAL_StatusTypeDef  HAL_NAND_RegisterCallback(NAND_HandleTypeDef *hnand, HAL_NAND_CallbackIDTypeDef CallbackId,
-
 
244
                                             pNAND_CallbackTypeDef pCallback);
-
 
245
HAL_StatusTypeDef  HAL_NAND_UnRegisterCallback(NAND_HandleTypeDef *hnand, HAL_NAND_CallbackIDTypeDef CallbackId);
-
 
246
#endif
-
 
247
 
215
/**
248
/**
216
  * @}
249
  * @}
217
  */
250
  */
218
 
251
 
219
/** @addtogroup NAND_Exported_Functions_Group3 Peripheral Control functions
252
/** @addtogroup NAND_Exported_Functions_Group3 Peripheral Control functions
220
  * @{
253
  * @{
221
  */
254
  */
222
 
255
 
223
/* NAND Control functions  ****************************************************/
256
/* NAND Control functions  ****************************************************/
224
HAL_StatusTypeDef  HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand);
257
HAL_StatusTypeDef  HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand);
Line 226... Line 259...
226
HAL_StatusTypeDef  HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, uint32_t Timeout);
259
HAL_StatusTypeDef  HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, uint32_t Timeout);
227
 
260
 
228
/**
261
/**
229
  * @}
262
  * @}
230
  */
263
  */
231
   
264
 
232
/** @defgroup NAND_Exported_Functions_Group4 Peripheral State functions
265
/** @addtogroup NAND_Exported_Functions_Group4 Peripheral State functions
233
  * @{
266
  * @{
234
  */
267
  */
235
 
-
 
236
/* NAND State functions *******************************************************/
268
/* NAND State functions *******************************************************/
237
HAL_NAND_StateTypeDef HAL_NAND_GetState(NAND_HandleTypeDef *hnand);
269
HAL_NAND_StateTypeDef HAL_NAND_GetState(NAND_HandleTypeDef *hnand);
238
uint32_t              HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand);
270
uint32_t              HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand);
239
 
-
 
240
/**
271
/**
241
  * @}
272
  * @}
242
  */
273
  */
243
   
274
 
244
/**
275
/**
245
  * @}
276
  * @}
246
  */
277
  */
-
 
278
 
247
/* Private types -------------------------------------------------------------*/
279
/* Private types -------------------------------------------------------------*/
248
/* Private variables ---------------------------------------------------------*/
280
/* Private variables ---------------------------------------------------------*/
249
/* Private constants ---------------------------------------------------------*/
281
/* Private constants ---------------------------------------------------------*/
250
/** @addtogroup NAND_Private_Constants
282
/** @defgroup NAND_Private_Constants NAND Private Constants
251
  * @{
283
  * @{
252
  */
284
  */
-
 
285
#define NAND_DEVICE1               0x70000000UL
-
 
286
#define NAND_DEVICE2               0x80000000UL
-
 
287
#define NAND_WRITE_TIMEOUT         0x01000000UL
253
 
288
 
254
#define NAND_DEVICE1               FSMC_BANK2
-
 
255
#define NAND_DEVICE2               FSMC_BANK3
-
 
256
#define NAND_WRITE_TIMEOUT         1000U
-
 
257
 
-
 
258
#define CMD_AREA                   (1U<<16U)  /* A16 = CLE high */
289
#define CMD_AREA                   (1UL<<16U)  /* A16 = CLE high */
259
#define ADDR_AREA                  (1U<<17U)  /* A17 = ALE high */
290
#define ADDR_AREA                  (1UL<<17U)  /* A17 = ALE high */
260
 
291
 
261
#define NAND_CMD_AREA_A            ((uint8_t)0x00)
292
#define NAND_CMD_AREA_A            ((uint8_t)0x00)
262
#define NAND_CMD_AREA_B            ((uint8_t)0x01)
293
#define NAND_CMD_AREA_B            ((uint8_t)0x01)
263
#define NAND_CMD_AREA_C            ((uint8_t)0x50)
294
#define NAND_CMD_AREA_C            ((uint8_t)0x50)
264
#define NAND_CMD_AREA_TRUE1        ((uint8_t)0x30)
295
#define NAND_CMD_AREA_TRUE1        ((uint8_t)0x30)
265
 
296
 
266
#define NAND_CMD_WRITE0            ((uint8_t)0x80)
297
#define NAND_CMD_WRITE0            ((uint8_t)0x80)
267
#define NAND_CMD_WRITE_TRUE1       ((uint8_t)0x10)  
298
#define NAND_CMD_WRITE_TRUE1       ((uint8_t)0x10)
268
#define NAND_CMD_ERASE0            ((uint8_t)0x60)
299
#define NAND_CMD_ERASE0            ((uint8_t)0x60)
269
#define NAND_CMD_ERASE1            ((uint8_t)0xD0)  
300
#define NAND_CMD_ERASE1            ((uint8_t)0xD0)
270
#define NAND_CMD_READID            ((uint8_t)0x90)  
301
#define NAND_CMD_READID            ((uint8_t)0x90)
271
#define NAND_CMD_STATUS            ((uint8_t)0x70)
302
#define NAND_CMD_STATUS            ((uint8_t)0x70)
272
#define NAND_CMD_LOCK_STATUS       ((uint8_t)0x7A)
303
#define NAND_CMD_LOCK_STATUS       ((uint8_t)0x7A)
273
#define NAND_CMD_RESET             ((uint8_t)0xFF)
304
#define NAND_CMD_RESET             ((uint8_t)0xFF)
274
 
305
 
275
/* NAND memory status */
306
/* NAND memory status */
276
#define NAND_VALID_ADDRESS         0x00000100U
307
#define NAND_VALID_ADDRESS         0x00000100UL
277
#define NAND_INVALID_ADDRESS       0x00000200U
308
#define NAND_INVALID_ADDRESS       0x00000200UL
278
#define NAND_TIMEOUT_ERROR         0x00000400U
309
#define NAND_TIMEOUT_ERROR         0x00000400UL
279
#define NAND_BUSY                  0x00000000U
310
#define NAND_BUSY                  0x00000000UL
280
#define NAND_ERROR                 0x00000001U
311
#define NAND_ERROR                 0x00000001UL
281
#define NAND_READY                 0x00000040U
312
#define NAND_READY                 0x00000040UL
282
 
-
 
283
/**
313
/**
284
  * @}
314
  * @}
285
  */
315
  */
286
 
316
 
287
/* Private macros ------------------------------------------------------------*/
317
/* Private macros ------------------------------------------------------------*/
288
/** @addtogroup NAND_Private_Macros
318
/** @defgroup NAND_Private_Macros NAND Private Macros
289
  * @{
319
  * @{
290
  */
320
  */
291
 
321
 
292
/**
322
/**
293
  * @brief  NAND memory address computation.
323
  * @brief  NAND memory address computation.
294
  * @param  __ADDRESS__: NAND memory address.
324
  * @param  __ADDRESS__ NAND memory address.
295
  * @param  __HANDLE__ : NAND handle.
325
  * @param  __HANDLE__  NAND handle.
296
  * @retval NAND Raw address value
326
  * @retval NAND Raw address value
297
  */
327
  */
298
#define ARRAY_ADDRESS(__ADDRESS__ , __HANDLE__) ((__ADDRESS__)->Page + \
328
#define ARRAY_ADDRESS(__ADDRESS__ , __HANDLE__) ((__ADDRESS__)->Page + \
299
                         (((__ADDRESS__)->Block + (((__ADDRESS__)->Plane) * ((__HANDLE__)->Config.PlaneSize)))* ((__HANDLE__)->Config.BlockSize)))
329
                                                 (((__ADDRESS__)->Block + (((__ADDRESS__)->Plane) * ((__HANDLE__)->Config.PlaneSize)))* ((__HANDLE__)->Config.BlockSize)))
300
 
330
 
301
/**
331
/**
302
  * @brief  NAND memory Column address computation.
332
  * @brief  NAND memory Column address computation.
303
  * @param  __HANDLE__: NAND handle.
333
  * @param  __HANDLE__ NAND handle.
304
  * @retval NAND Raw address value
334
  * @retval NAND Raw address value
305
  */
335
  */
306
#define COLUMN_ADDRESS( __HANDLE__) ((__HANDLE__)->Config.PageSize)
336
#define COLUMN_ADDRESS( __HANDLE__) ((__HANDLE__)->Config.PageSize)
307
   
337
 
308
/**
338
/**
309
  * @brief  NAND memory address cycling.
339
  * @brief  NAND memory address cycling.
310
  * @param  __ADDRESS__: NAND memory address.
340
  * @param  __ADDRESS__ NAND memory address.
311
  * @retval NAND address cycling value.
341
  * @retval NAND address cycling value.
312
  */
342
  */
313
#define ADDR_1ST_CYCLE(__ADDRESS__)       (uint8_t)(__ADDRESS__)               /* 1st addressing cycle */
343
#define ADDR_1ST_CYCLE(__ADDRESS__)       (uint8_t)(__ADDRESS__)              /* 1st addressing cycle */
314
#define ADDR_2ND_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) >> 8U)       /* 2nd addressing cycle */
344
#define ADDR_2ND_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) >> 8)       /* 2nd addressing cycle */
315
#define ADDR_3RD_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) >> 16U)      /* 3rd addressing cycle */
345
#define ADDR_3RD_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) >> 16)      /* 3rd addressing cycle */
316
#define ADDR_4TH_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) >> 24U)      /* 4th addressing cycle */
346
#define ADDR_4TH_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) >> 24)      /* 4th addressing cycle */
317
 
347
 
318
/**
348
/**
319
  * @brief  NAND memory Columns cycling.
349
  * @brief  NAND memory Columns cycling.
320
  * @param  __ADDRESS__: NAND memory address.
350
  * @param  __ADDRESS__ NAND memory address.
321
  * @retval NAND Column address cycling value.
351
  * @retval NAND Column address cycling value.
322
  */
352
  */
323
#define COLUMN_1ST_CYCLE(__ADDRESS__)       (uint8_t)(__ADDRESS__)              /* 1st Column addressing cycle */
353
#define COLUMN_1ST_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) & 0xFFU)    /* 1st Column addressing cycle */
324
#define COLUMN_2ND_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) >> 8U)      /* 2nd Column addressing cycle */
354
#define COLUMN_2ND_CYCLE(__ADDRESS__)       (uint8_t)((__ADDRESS__) >> 8)       /* 2nd Column addressing cycle */
-
 
355
 
-
 
356
/**
-
 
357
  * @}
-
 
358
  */
325
 
359
 
326
/**
360
/**
327
  * @}
361
  * @}
328
  */
362
  */
329
   
363
 
330
/**
364
/**
331
  * @}
365
  * @}
332
  */
366
  */
333
#endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */
-
 
334
 
367
 
335
/**
368
/**
336
  * @}
369
  * @}
337
  */
370
  */
-
 
371
 
-
 
372
#endif /* FSMC_BANK3 */
338
 
373
 
339
#ifdef __cplusplus
374
#ifdef __cplusplus
340
}
375
}
341
#endif
376
#endif
342
 
377
 
343
#endif /* __STM32F1xx_HAL_NAND_H */
378
#endif /* STM32F1xx_HAL_NAND_H */
344
 
379
 
345
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
380
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/