mbed library sources

Fork of mbed-src by mbed official

Committer:
moirans2
Date:
Wed Jan 14 20:53:08 2015 +0000
Revision:
445:9a3ffe6cfa19
Parent:
385:be64abf45658
internal clock stm32L051

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 375:3d36234a1087 1 /**
mbed_official 375:3d36234a1087 2 ******************************************************************************
mbed_official 375:3d36234a1087 3 * @file stm32f3xx_hal_nand.h
mbed_official 375:3d36234a1087 4 * @author MCD Application Team
mbed_official 375:3d36234a1087 5 * @version V1.1.0
mbed_official 375:3d36234a1087 6 * @date 12-Sept-2014
mbed_official 375:3d36234a1087 7 * @brief Header file of NAND HAL module.
mbed_official 375:3d36234a1087 8 ******************************************************************************
mbed_official 375:3d36234a1087 9 * @attention
mbed_official 375:3d36234a1087 10 *
mbed_official 375:3d36234a1087 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 375:3d36234a1087 12 *
mbed_official 375:3d36234a1087 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 375:3d36234a1087 14 * are permitted provided that the following conditions are met:
mbed_official 375:3d36234a1087 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 375:3d36234a1087 16 * this list of conditions and the following disclaimer.
mbed_official 375:3d36234a1087 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 375:3d36234a1087 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 375:3d36234a1087 19 * and/or other materials provided with the distribution.
mbed_official 375:3d36234a1087 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 375:3d36234a1087 21 * may be used to endorse or promote products derived from this software
mbed_official 375:3d36234a1087 22 * without specific prior written permission.
mbed_official 375:3d36234a1087 23 *
mbed_official 375:3d36234a1087 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 375:3d36234a1087 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 375:3d36234a1087 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 375:3d36234a1087 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 375:3d36234a1087 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 375:3d36234a1087 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 375:3d36234a1087 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 375:3d36234a1087 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 375:3d36234a1087 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 375:3d36234a1087 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 375:3d36234a1087 34 *
mbed_official 375:3d36234a1087 35 ******************************************************************************
mbed_official 375:3d36234a1087 36 */
mbed_official 375:3d36234a1087 37
mbed_official 375:3d36234a1087 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 375:3d36234a1087 39 #ifndef __STM32F3xx_HAL_NAND_H
mbed_official 375:3d36234a1087 40 #define __STM32F3xx_HAL_NAND_H
mbed_official 375:3d36234a1087 41
mbed_official 375:3d36234a1087 42 #ifdef __cplusplus
mbed_official 375:3d36234a1087 43 extern "C" {
mbed_official 375:3d36234a1087 44 #endif
mbed_official 375:3d36234a1087 45
mbed_official 375:3d36234a1087 46 /* Includes ------------------------------------------------------------------*/
mbed_official 375:3d36234a1087 47 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx)
mbed_official 375:3d36234a1087 48 #include "stm32f3xx_ll_fmc.h"
mbed_official 375:3d36234a1087 49 #endif /* STM32F302xE || STM32F303xE || STM32F398xx */
mbed_official 375:3d36234a1087 50
mbed_official 375:3d36234a1087 51 /** @addtogroup STM32F3xx_HAL_Driver
mbed_official 375:3d36234a1087 52 * @{
mbed_official 375:3d36234a1087 53 */
mbed_official 375:3d36234a1087 54
mbed_official 375:3d36234a1087 55 /** @addtogroup NAND
mbed_official 375:3d36234a1087 56 * @{
mbed_official 375:3d36234a1087 57 */
mbed_official 375:3d36234a1087 58
mbed_official 375:3d36234a1087 59 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx)
mbed_official 375:3d36234a1087 60
mbed_official 375:3d36234a1087 61 /* Exported typedef ----------------------------------------------------------*/
mbed_official 375:3d36234a1087 62 /* Exported types ------------------------------------------------------------*/
mbed_official 375:3d36234a1087 63 /** @defgroup NAND_Exported_Types NAND Exported Types
mbed_official 375:3d36234a1087 64 * @{
mbed_official 375:3d36234a1087 65 */
mbed_official 375:3d36234a1087 66
mbed_official 375:3d36234a1087 67 /**
mbed_official 375:3d36234a1087 68 * @brief HAL NAND State structures definition
mbed_official 375:3d36234a1087 69 */
mbed_official 375:3d36234a1087 70 typedef enum
mbed_official 375:3d36234a1087 71 {
mbed_official 375:3d36234a1087 72 HAL_NAND_STATE_RESET = 0x00, /*!< NAND not yet initialized or disabled */
mbed_official 375:3d36234a1087 73 HAL_NAND_STATE_READY = 0x01, /*!< NAND initialized and ready for use */
mbed_official 375:3d36234a1087 74 HAL_NAND_STATE_BUSY = 0x02, /*!< NAND internal process is ongoing */
mbed_official 375:3d36234a1087 75 HAL_NAND_STATE_ERROR = 0x03 /*!< NAND error state */
mbed_official 375:3d36234a1087 76 }HAL_NAND_StateTypeDef;
mbed_official 375:3d36234a1087 77
mbed_official 375:3d36234a1087 78 /**
mbed_official 375:3d36234a1087 79 * @brief NAND Memory electronic signature Structure definition
mbed_official 375:3d36234a1087 80 */
mbed_official 375:3d36234a1087 81 typedef struct
mbed_official 375:3d36234a1087 82 {
mbed_official 375:3d36234a1087 83 /*<! NAND memory electronic signature maker and device IDs */
mbed_official 375:3d36234a1087 84
mbed_official 375:3d36234a1087 85 uint8_t Maker_Id;
mbed_official 375:3d36234a1087 86
mbed_official 375:3d36234a1087 87 uint8_t Device_Id;
mbed_official 375:3d36234a1087 88
mbed_official 375:3d36234a1087 89 uint8_t Third_Id;
mbed_official 375:3d36234a1087 90
mbed_official 375:3d36234a1087 91 uint8_t Fourth_Id;
mbed_official 375:3d36234a1087 92 }NAND_IDTypeDef;
mbed_official 375:3d36234a1087 93
mbed_official 375:3d36234a1087 94 /**
mbed_official 375:3d36234a1087 95 * @brief NAND Memory address Structure definition
mbed_official 375:3d36234a1087 96 */
mbed_official 375:3d36234a1087 97 typedef struct
mbed_official 375:3d36234a1087 98 {
mbed_official 375:3d36234a1087 99 uint16_t Page; /*!< NAND memory Page address */
mbed_official 375:3d36234a1087 100
mbed_official 375:3d36234a1087 101 uint16_t Zone; /*!< NAND memory Zone address */
mbed_official 375:3d36234a1087 102
mbed_official 375:3d36234a1087 103 uint16_t Block; /*!< NAND memory Block address */
mbed_official 375:3d36234a1087 104
mbed_official 375:3d36234a1087 105 }NAND_AddressTypedef;
mbed_official 375:3d36234a1087 106
mbed_official 375:3d36234a1087 107 /**
mbed_official 375:3d36234a1087 108 * @brief NAND Memory info Structure definition
mbed_official 375:3d36234a1087 109 */
mbed_official 375:3d36234a1087 110 typedef struct
mbed_official 375:3d36234a1087 111 {
mbed_official 375:3d36234a1087 112 uint32_t PageSize; /*!< NAND memory page (without spare area) size measured in K. bytes */
mbed_official 375:3d36234a1087 113
mbed_official 375:3d36234a1087 114 uint32_t SpareAreaSize; /*!< NAND memory spare area size measured in K. bytes */
mbed_official 375:3d36234a1087 115
mbed_official 375:3d36234a1087 116 uint32_t BlockSize; /*!< NAND memory block size number of pages */
mbed_official 375:3d36234a1087 117
mbed_official 375:3d36234a1087 118 uint32_t BlockNbr; /*!< NAND memory number of blocks */
mbed_official 375:3d36234a1087 119
mbed_official 375:3d36234a1087 120 uint32_t ZoneSize; /*!< NAND memory zone size measured in number of blocks */
mbed_official 375:3d36234a1087 121 }NAND_InfoTypeDef;
mbed_official 375:3d36234a1087 122
mbed_official 375:3d36234a1087 123 /**
mbed_official 375:3d36234a1087 124 * @brief NAND handle Structure definition
mbed_official 375:3d36234a1087 125 */
mbed_official 375:3d36234a1087 126 typedef struct
mbed_official 375:3d36234a1087 127 {
mbed_official 375:3d36234a1087 128 FMC_NAND_TypeDef *Instance; /*!< Register base address */
mbed_official 375:3d36234a1087 129
mbed_official 375:3d36234a1087 130 FMC_NAND_InitTypeDef Init; /*!< NAND device control configuration parameters */
mbed_official 375:3d36234a1087 131
mbed_official 375:3d36234a1087 132 HAL_LockTypeDef Lock; /*!< NAND locking object */
mbed_official 375:3d36234a1087 133
mbed_official 375:3d36234a1087 134 __IO HAL_NAND_StateTypeDef State; /*!< NAND device access state */
mbed_official 375:3d36234a1087 135
mbed_official 375:3d36234a1087 136 NAND_InfoTypeDef Info; /*!< NAND characteristic information structure */
mbed_official 375:3d36234a1087 137 }NAND_HandleTypeDef;
mbed_official 375:3d36234a1087 138
mbed_official 375:3d36234a1087 139 /**
mbed_official 375:3d36234a1087 140 * @}
mbed_official 375:3d36234a1087 141 */
mbed_official 375:3d36234a1087 142
mbed_official 375:3d36234a1087 143 /* Exported constants --------------------------------------------------------*/
mbed_official 375:3d36234a1087 144 /** @defgroup NAND_Exported_Constants NAND Exported Constants
mbed_official 375:3d36234a1087 145 * @{
mbed_official 375:3d36234a1087 146 */
mbed_official 375:3d36234a1087 147 #define NAND_DEVICE1 ((uint32_t)0x70000000)
mbed_official 375:3d36234a1087 148 #define NAND_DEVICE2 ((uint32_t)0x80000000)
mbed_official 375:3d36234a1087 149 #define NAND_WRITE_TIMEOUT ((uint32_t)0x01000000)
mbed_official 375:3d36234a1087 150
mbed_official 375:3d36234a1087 151 #define CMD_AREA ((uint32_t)(1<<16)) /* A16 = CLE high */
mbed_official 375:3d36234a1087 152 #define ADDR_AREA ((uint32_t)(1<<17)) /* A17 = ALE high */
mbed_official 375:3d36234a1087 153
mbed_official 375:3d36234a1087 154 #define NAND_CMD_AREA_A ((uint8_t)0x00)
mbed_official 375:3d36234a1087 155 #define NAND_CMD_AREA_B ((uint8_t)0x01)
mbed_official 375:3d36234a1087 156 #define NAND_CMD_AREA_C ((uint8_t)0x50)
mbed_official 375:3d36234a1087 157
mbed_official 375:3d36234a1087 158 /* NAND memory status */
mbed_official 375:3d36234a1087 159 #define NAND_VALID_ADDRESS ((uint32_t)0x00000100)
mbed_official 375:3d36234a1087 160 #define NAND_INVALID_ADDRESS ((uint32_t)0x00000200)
mbed_official 375:3d36234a1087 161 #define NAND_TIMEOUT_ERROR ((uint32_t)0x00000400)
mbed_official 375:3d36234a1087 162 #define NAND_BUSY ((uint32_t)0x00000000)
mbed_official 375:3d36234a1087 163 #define NAND_ERROR ((uint32_t)0x00000001)
mbed_official 375:3d36234a1087 164 #define NAND_READY ((uint32_t)0x00000040)
mbed_official 375:3d36234a1087 165
mbed_official 375:3d36234a1087 166 /**
mbed_official 375:3d36234a1087 167 * @}
mbed_official 375:3d36234a1087 168 */
mbed_official 375:3d36234a1087 169
mbed_official 375:3d36234a1087 170 /* Exported macro ------------------------------------------------------------*/
mbed_official 375:3d36234a1087 171 /** @defgroup NAND_Exported_Macros NAND Exported Macros
mbed_official 375:3d36234a1087 172 * @{
mbed_official 375:3d36234a1087 173 */
mbed_official 375:3d36234a1087 174
mbed_official 375:3d36234a1087 175 /** @brief Reset NAND handle state
mbed_official 375:3d36234a1087 176 * @param __HANDLE__: specifies the NAND handle.
mbed_official 375:3d36234a1087 177 * @retval None
mbed_official 375:3d36234a1087 178 */
mbed_official 375:3d36234a1087 179 #define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NAND_STATE_RESET)
mbed_official 375:3d36234a1087 180
mbed_official 375:3d36234a1087 181 /**
mbed_official 375:3d36234a1087 182 * @brief NAND memory address computation.
mbed_official 375:3d36234a1087 183 * @param __ADDRESS__: NAND memory address.
mbed_official 375:3d36234a1087 184 * @param __HANDLE__ : NAND handle.
mbed_official 375:3d36234a1087 185 * @retval NAND Raw address value
mbed_official 375:3d36234a1087 186 */
mbed_official 375:3d36234a1087 187 #define ARRAY_ADDRESS(__ADDRESS__ , __HANDLE__) ((__ADDRESS__)->Page + (((__ADDRESS__)->Block + (((__ADDRESS__)->Zone) * ((__HANDLE__)->Info.ZoneSize)))* ((__HANDLE__)->Info.BlockSize)))
mbed_official 375:3d36234a1087 188
mbed_official 375:3d36234a1087 189 /**
mbed_official 375:3d36234a1087 190 * @brief NAND memory address cycling.
mbed_official 375:3d36234a1087 191 * @param __ADDRESS__: NAND memory address.
mbed_official 375:3d36234a1087 192 * @retval NAND address cycling value.
mbed_official 375:3d36234a1087 193 */
mbed_official 375:3d36234a1087 194 #define ADDR_1st_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__)& 0xFF) /* 1st addressing cycle */
mbed_official 375:3d36234a1087 195 #define ADDR_2nd_CYCLE(__ADDRESS__) (uint8_t)(((__ADDRESS__)& 0xFF00) >> 8) /* 2nd addressing cycle */
mbed_official 375:3d36234a1087 196 #define ADDR_3rd_CYCLE(__ADDRESS__) (uint8_t)(((__ADDRESS__)& 0xFF0000) >> 16) /* 3rd addressing cycle */
mbed_official 375:3d36234a1087 197 #define ADDR_4th_CYCLE(__ADDRESS__) (uint8_t)(((__ADDRESS__)& 0xFF000000) >> 24) /* 4th addressing cycle */
mbed_official 375:3d36234a1087 198 /**
mbed_official 375:3d36234a1087 199 * @}
mbed_official 375:3d36234a1087 200 */
mbed_official 375:3d36234a1087 201
mbed_official 375:3d36234a1087 202 /* Exported functions --------------------------------------------------------*/
mbed_official 375:3d36234a1087 203 /** @addtogroup NAND_Exported_Functions NAND Exported Functions
mbed_official 375:3d36234a1087 204 * @{
mbed_official 375:3d36234a1087 205 */
mbed_official 375:3d36234a1087 206
mbed_official 375:3d36234a1087 207 /** @addtogroup NAND_Exported_Functions_Group1 Initialization and de-initialization functions
mbed_official 375:3d36234a1087 208 * @{
mbed_official 375:3d36234a1087 209 */
mbed_official 375:3d36234a1087 210
mbed_official 375:3d36234a1087 211 /* Initialization/de-initialization functions ********************************/
mbed_official 375:3d36234a1087 212 HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingTypeDef *ComSpace_Timing, FMC_NAND_PCC_TimingTypeDef *AttSpace_Timing);
mbed_official 375:3d36234a1087 213 HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 214 void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 215 void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 216 void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 217 void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 218
mbed_official 375:3d36234a1087 219 /**
mbed_official 375:3d36234a1087 220 * @}
mbed_official 375:3d36234a1087 221 */
mbed_official 375:3d36234a1087 222
mbed_official 375:3d36234a1087 223 /** @addtogroup NAND_Exported_Functions_Group2 Input and Output functions
mbed_official 375:3d36234a1087 224 * @{
mbed_official 375:3d36234a1087 225 */
mbed_official 375:3d36234a1087 226
mbed_official 375:3d36234a1087 227 /* IO operation functions ****************************************************/
mbed_official 375:3d36234a1087 228 HAL_StatusTypeDef HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID);
mbed_official 375:3d36234a1087 229 HAL_StatusTypeDef HAL_NAND_Reset(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 230 HAL_StatusTypeDef HAL_NAND_Read_Page(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumPageToRead);
mbed_official 375:3d36234a1087 231 HAL_StatusTypeDef HAL_NAND_Write_Page(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumPageToWrite);
mbed_official 375:3d36234a1087 232 HAL_StatusTypeDef HAL_NAND_Read_SpareArea(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumSpareAreaToRead);
mbed_official 375:3d36234a1087 233 HAL_StatusTypeDef HAL_NAND_Write_SpareArea(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumSpareAreaTowrite);
mbed_official 375:3d36234a1087 234 HAL_StatusTypeDef HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress);
mbed_official 375:3d36234a1087 235 uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 236 uint32_t HAL_NAND_Address_Inc(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress);
mbed_official 375:3d36234a1087 237
mbed_official 375:3d36234a1087 238 /**
mbed_official 375:3d36234a1087 239 * @}
mbed_official 375:3d36234a1087 240 */
mbed_official 375:3d36234a1087 241
mbed_official 375:3d36234a1087 242 /** @addtogroup NAND_Exported_Functions_Group3 Peripheral Control functions
mbed_official 375:3d36234a1087 243 * @{
mbed_official 375:3d36234a1087 244 */
mbed_official 375:3d36234a1087 245
mbed_official 375:3d36234a1087 246 /* NAND Control functions ****************************************************/
mbed_official 375:3d36234a1087 247 HAL_StatusTypeDef HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 248 HAL_StatusTypeDef HAL_NAND_ECC_Disable(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 249 HAL_StatusTypeDef HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, uint32_t Timeout);
mbed_official 375:3d36234a1087 250
mbed_official 375:3d36234a1087 251 /**
mbed_official 375:3d36234a1087 252 * @}
mbed_official 375:3d36234a1087 253 */
mbed_official 375:3d36234a1087 254
mbed_official 375:3d36234a1087 255 /** @defgroup NAND_Exported_Functions_Group4 Peripheral State functions
mbed_official 375:3d36234a1087 256 * @{
mbed_official 375:3d36234a1087 257 */
mbed_official 375:3d36234a1087 258
mbed_official 375:3d36234a1087 259 /* NAND State functions *******************************************************/
mbed_official 375:3d36234a1087 260 HAL_NAND_StateTypeDef HAL_NAND_GetState(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 261 uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand);
mbed_official 375:3d36234a1087 262
mbed_official 375:3d36234a1087 263 /**
mbed_official 375:3d36234a1087 264 * @}
mbed_official 375:3d36234a1087 265 */
mbed_official 375:3d36234a1087 266
mbed_official 375:3d36234a1087 267 /**
mbed_official 375:3d36234a1087 268 * @}
mbed_official 375:3d36234a1087 269 */
mbed_official 375:3d36234a1087 270
mbed_official 375:3d36234a1087 271 #endif /* STM32F302xE || STM32F303xE || STM32F398xx */
mbed_official 375:3d36234a1087 272 /**
mbed_official 375:3d36234a1087 273 * @}
mbed_official 375:3d36234a1087 274 */
mbed_official 375:3d36234a1087 275
mbed_official 375:3d36234a1087 276 /**
mbed_official 375:3d36234a1087 277 * @}
mbed_official 375:3d36234a1087 278 */
mbed_official 375:3d36234a1087 279
mbed_official 375:3d36234a1087 280 #ifdef __cplusplus
mbed_official 375:3d36234a1087 281 }
mbed_official 375:3d36234a1087 282 #endif
mbed_official 375:3d36234a1087 283
mbed_official 375:3d36234a1087 284 #endif /* __STM32F3xx_HAL_NAND_H */
mbed_official 375:3d36234a1087 285
mbed_official 375:3d36234a1087 286 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/