mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Jun 27 07:30:09 2014 +0100
Revision:
242:7074e42da0b2
Parent:
133:d4dda5c437f0
Synchronized with git revision 124ef5e3add9e74a3221347a3fbeea7c8b3cf353

Full URL: https://github.com/mbedmicro/mbed/commit/124ef5e3add9e74a3221347a3fbeea7c8b3cf353/

[DISCO_F407VG] HAL update.

Who changed what in which revision?

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