mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
296:ec1b66a3d094
test with CLOCK_SETUP = 0

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_nor.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 NOR 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 133:d4dda5c437f0 36 */
mbed_official 133:d4dda5c437f0 37
mbed_official 133:d4dda5c437f0 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 133:d4dda5c437f0 39 #ifndef __STM32F4xx_HAL_NOR_H
mbed_official 133:d4dda5c437f0 40 #define __STM32F4xx_HAL_NOR_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 NOR
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 /**
mbed_official 133:d4dda5c437f0 67 * @brief HAL SRAM State structures definition
mbed_official 133:d4dda5c437f0 68 */
mbed_official 133:d4dda5c437f0 69 typedef enum
mbed_official 133:d4dda5c437f0 70 {
mbed_official 133:d4dda5c437f0 71 HAL_NOR_STATE_RESET = 0x00, /*!< NOR not yet initialized or disabled */
mbed_official 133:d4dda5c437f0 72 HAL_NOR_STATE_READY = 0x01, /*!< NOR initialized and ready for use */
mbed_official 133:d4dda5c437f0 73 HAL_NOR_STATE_BUSY = 0x02, /*!< NOR internal processing is ongoing */
mbed_official 242:7074e42da0b2 74 HAL_NOR_STATE_ERROR = 0x03, /*!< NOR error state */
mbed_official 242:7074e42da0b2 75 HAL_NOR_STATE_PROTECTED = 0x04 /*!< NOR NORSRAM device write protected */
mbed_official 242:7074e42da0b2 76 }HAL_NOR_StateTypeDef;
mbed_official 133:d4dda5c437f0 77
mbed_official 133:d4dda5c437f0 78 /**
mbed_official 133:d4dda5c437f0 79 * @brief FMC NOR Status typedef
mbed_official 133:d4dda5c437f0 80 */
mbed_official 133:d4dda5c437f0 81 typedef enum
mbed_official 133:d4dda5c437f0 82 {
mbed_official 133:d4dda5c437f0 83 NOR_SUCCESS = 0,
mbed_official 133:d4dda5c437f0 84 NOR_ONGOING,
mbed_official 133:d4dda5c437f0 85 NOR_ERROR,
mbed_official 133:d4dda5c437f0 86 NOR_TIMEOUT
mbed_official 242:7074e42da0b2 87 }NOR_StatusTypedef;
mbed_official 133:d4dda5c437f0 88
mbed_official 133:d4dda5c437f0 89 /**
mbed_official 133:d4dda5c437f0 90 * @brief FMC NOR ID typedef
mbed_official 133:d4dda5c437f0 91 */
mbed_official 133:d4dda5c437f0 92 typedef struct
mbed_official 133:d4dda5c437f0 93 {
mbed_official 133:d4dda5c437f0 94 uint16_t Manufacturer_Code; /*!< Defines the device's manufacturer code used to identify the memory */
mbed_official 242:7074e42da0b2 95
mbed_official 242:7074e42da0b2 96 uint16_t Device_Code1;
mbed_official 242:7074e42da0b2 97
mbed_official 242:7074e42da0b2 98 uint16_t Device_Code2;
mbed_official 242:7074e42da0b2 99
mbed_official 242:7074e42da0b2 100 uint16_t Device_Code3; /*!< Defines the devices' codes used to identify the memory.
mbed_official 133:d4dda5c437f0 101 These codes can be accessed by performing read operations with specific
mbed_official 133:d4dda5c437f0 102 control signals and addresses set.They can also be accessed by issuing
mbed_official 242:7074e42da0b2 103 an Auto Select command */
mbed_official 133:d4dda5c437f0 104 }NOR_IDTypeDef;
mbed_official 133:d4dda5c437f0 105
mbed_official 133:d4dda5c437f0 106 /**
mbed_official 133:d4dda5c437f0 107 * @brief FMC NOR CFI typedef
mbed_official 133:d4dda5c437f0 108 */
mbed_official 133:d4dda5c437f0 109 typedef struct
mbed_official 133:d4dda5c437f0 110 {
mbed_official 133:d4dda5c437f0 111 /*!< Defines the information stored in the memory's Common flash interface
mbed_official 133:d4dda5c437f0 112 which contains a description of various electrical and timing parameters,
mbed_official 133:d4dda5c437f0 113 density information and functions supported by the memory */
mbed_official 242:7074e42da0b2 114
mbed_official 242:7074e42da0b2 115 uint16_t CFI_1;
mbed_official 242:7074e42da0b2 116
mbed_official 242:7074e42da0b2 117 uint16_t CFI_2;
mbed_official 242:7074e42da0b2 118
mbed_official 242:7074e42da0b2 119 uint16_t CFI_3;
mbed_official 242:7074e42da0b2 120
mbed_official 242:7074e42da0b2 121 uint16_t CFI_4;
mbed_official 133:d4dda5c437f0 122 }NOR_CFITypeDef;
mbed_official 133:d4dda5c437f0 123
mbed_official 133:d4dda5c437f0 124 /**
mbed_official 242:7074e42da0b2 125 * @brief NOR handle Structure definition
mbed_official 133:d4dda5c437f0 126 */
mbed_official 133:d4dda5c437f0 127 typedef struct
mbed_official 133:d4dda5c437f0 128 {
mbed_official 242:7074e42da0b2 129 FMC_NORSRAM_TypeDef *Instance; /*!< Register base address */
mbed_official 242:7074e42da0b2 130
mbed_official 133:d4dda5c437f0 131 FMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */
mbed_official 242:7074e42da0b2 132
mbed_official 133:d4dda5c437f0 133 FMC_NORSRAM_InitTypeDef Init; /*!< NOR device control configuration parameters */
mbed_official 133:d4dda5c437f0 134
mbed_official 242:7074e42da0b2 135 HAL_LockTypeDef Lock; /*!< NOR locking object */
mbed_official 242:7074e42da0b2 136
mbed_official 133:d4dda5c437f0 137 __IO HAL_NOR_StateTypeDef State; /*!< NOR device access state */
mbed_official 242:7074e42da0b2 138
mbed_official 133:d4dda5c437f0 139 }NOR_HandleTypeDef;
mbed_official 133:d4dda5c437f0 140
mbed_official 133:d4dda5c437f0 141 /* Exported constants --------------------------------------------------------*/
mbed_official 133:d4dda5c437f0 142 /** @defgroup NOR_Exported_Constants
mbed_official 133:d4dda5c437f0 143 * @{
mbed_official 133:d4dda5c437f0 144 */
mbed_official 133:d4dda5c437f0 145 /* NOR device IDs addresses */
mbed_official 133:d4dda5c437f0 146 #define MC_ADDRESS ((uint16_t)0x0000)
mbed_official 133:d4dda5c437f0 147 #define DEVICE_CODE1_ADDR ((uint16_t)0x0001)
mbed_official 133:d4dda5c437f0 148 #define DEVICE_CODE2_ADDR ((uint16_t)0x000E)
mbed_official 133:d4dda5c437f0 149 #define DEVICE_CODE3_ADDR ((uint16_t)0x000F)
mbed_official 133:d4dda5c437f0 150
mbed_official 133:d4dda5c437f0 151 /* NOR CFI IDs addresses */
mbed_official 133:d4dda5c437f0 152 #define CFI1_ADDRESS ((uint16_t)0x61)
mbed_official 133:d4dda5c437f0 153 #define CFI2_ADDRESS ((uint16_t)0x62)
mbed_official 133:d4dda5c437f0 154 #define CFI3_ADDRESS ((uint16_t)0x63)
mbed_official 133:d4dda5c437f0 155 #define CFI4_ADDRESS ((uint16_t)0x64)
mbed_official 133:d4dda5c437f0 156
mbed_official 133:d4dda5c437f0 157 /* NOR operation wait timeout */
mbed_official 133:d4dda5c437f0 158 #define NOR_TMEOUT ((uint16_t)0xFFFF)
mbed_official 133:d4dda5c437f0 159
mbed_official 133:d4dda5c437f0 160 /* #define NOR_MEMORY_16B */
mbed_official 133:d4dda5c437f0 161 #define NOR_MEMORY_8B
mbed_official 133:d4dda5c437f0 162
mbed_official 133:d4dda5c437f0 163 /* NOR memory device read/write start address */
mbed_official 133:d4dda5c437f0 164 #define NOR_MEMORY_ADRESS ((uint32_t)0x60000000)
mbed_official 133:d4dda5c437f0 165
mbed_official 133:d4dda5c437f0 166 /**
mbed_official 133:d4dda5c437f0 167 * @}
mbed_official 133:d4dda5c437f0 168 */
mbed_official 133:d4dda5c437f0 169
mbed_official 133:d4dda5c437f0 170 /* Exported macro ------------------------------------------------------------*/
mbed_official 242:7074e42da0b2 171
mbed_official 242:7074e42da0b2 172 /** @brief Reset NOR handle state
mbed_official 242:7074e42da0b2 173 * @param __HANDLE__: specifies the NOR handle.
mbed_official 242:7074e42da0b2 174 * @retval None
mbed_official 242:7074e42da0b2 175 */
mbed_official 242:7074e42da0b2 176 #define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NOR_STATE_RESET)
mbed_official 242:7074e42da0b2 177
mbed_official 133:d4dda5c437f0 178 /**
mbed_official 133:d4dda5c437f0 179 * @brief NOR memory address shifting.
mbed_official 133:d4dda5c437f0 180 * @param __ADDRESS__: NOR memory address
mbed_official 133:d4dda5c437f0 181 * @retval NOR shifted address value
mbed_official 133:d4dda5c437f0 182 */
mbed_official 133:d4dda5c437f0 183 #ifdef NOR_MEMORY_8B
mbed_official 133:d4dda5c437f0 184 #define __NOR_ADDR_SHIFT(__ADDRESS__) (uint32_t)(NOR_MEMORY_ADRESS + (2 * (__ADDRESS__)))
mbed_official 133:d4dda5c437f0 185 #else /* NOR_MEMORY_16B */
mbed_official 133:d4dda5c437f0 186 #define __NOR_ADDR_SHIFT(__ADDRESS__) (uint32_t)(NOR_MEMORY_ADRESS + (__ADDRESS__))
mbed_official 133:d4dda5c437f0 187 #endif /* NOR_MEMORY_8B */
mbed_official 133:d4dda5c437f0 188
mbed_official 133:d4dda5c437f0 189 /**
mbed_official 133:d4dda5c437f0 190 * @brief NOR memory write data to specified address.
mbed_official 133:d4dda5c437f0 191 * @param __ADDRESS__: NOR memory address
mbed_official 133:d4dda5c437f0 192 * @param __DATA__: Data to write
mbed_official 133:d4dda5c437f0 193 * @retval None
mbed_official 133:d4dda5c437f0 194 */
mbed_official 133:d4dda5c437f0 195 #define __NOR_WRITE(__ADDRESS__, __DATA__) (*(__IO uint16_t *)((uint32_t)(__ADDRESS__)) = (__DATA__))
mbed_official 133:d4dda5c437f0 196
mbed_official 133:d4dda5c437f0 197 /* Exported functions --------------------------------------------------------*/
mbed_official 133:d4dda5c437f0 198
mbed_official 242:7074e42da0b2 199 /* Initialization/de-initialization functions ********************************/
mbed_official 133:d4dda5c437f0 200 HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming);
mbed_official 133:d4dda5c437f0 201 HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor);
mbed_official 133:d4dda5c437f0 202 void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor);
mbed_official 133:d4dda5c437f0 203 void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor);
mbed_official 133:d4dda5c437f0 204 void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout);
mbed_official 133:d4dda5c437f0 205
mbed_official 242:7074e42da0b2 206 /* I/O operation functions ***************************************************/
mbed_official 133:d4dda5c437f0 207 HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID);
mbed_official 133:d4dda5c437f0 208 HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor);
mbed_official 133:d4dda5c437f0 209 HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData);
mbed_official 133:d4dda5c437f0 210 HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData);
mbed_official 133:d4dda5c437f0 211
mbed_official 133:d4dda5c437f0 212 HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize);
mbed_official 133:d4dda5c437f0 213 HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize);
mbed_official 133:d4dda5c437f0 214
mbed_official 133:d4dda5c437f0 215 HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address);
mbed_official 133:d4dda5c437f0 216 HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address);
mbed_official 133:d4dda5c437f0 217 HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI);
mbed_official 133:d4dda5c437f0 218
mbed_official 242:7074e42da0b2 219 /* NOR Control functions *****************************************************/
mbed_official 133:d4dda5c437f0 220 HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor);
mbed_official 133:d4dda5c437f0 221 HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor);
mbed_official 133:d4dda5c437f0 222
mbed_official 242:7074e42da0b2 223 /* NOR State functions ********************************************************/
mbed_official 133:d4dda5c437f0 224 HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor);
mbed_official 133:d4dda5c437f0 225 NOR_StatusTypedef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout);
mbed_official 133:d4dda5c437f0 226
mbed_official 133:d4dda5c437f0 227 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
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 * @}
mbed_official 133:d4dda5c437f0 234 */
mbed_official 133:d4dda5c437f0 235
mbed_official 133:d4dda5c437f0 236 #ifdef __cplusplus
mbed_official 133:d4dda5c437f0 237 }
mbed_official 133:d4dda5c437f0 238 #endif
mbed_official 133:d4dda5c437f0 239
mbed_official 133:d4dda5c437f0 240 #endif /* __STM32F4xx_HAL_NOR_H */
mbed_official 133:d4dda5c437f0 241
mbed_official 133:d4dda5c437f0 242 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/