The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Jun 21 17:31:38 2017 +0100
Revision:
145:64910690c574
Parent:
128:9bcdf88f62b0
Release 145 of the mbed library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 122:f9eeca106725 1 /**
Kojto 122:f9eeca106725 2 ******************************************************************************
Kojto 122:f9eeca106725 3 * @file stm32l4xx_hal_nor.h
Kojto 122:f9eeca106725 4 * @author MCD Application Team
AnnaBridge 145:64910690c574 5 * @version V1.7.1
AnnaBridge 145:64910690c574 6 * @date 21-April-2017
Kojto 122:f9eeca106725 7 * @brief Header file of NOR HAL module.
Kojto 122:f9eeca106725 8 ******************************************************************************
Kojto 122:f9eeca106725 9 * @attention
Kojto 122:f9eeca106725 10 *
AnnaBridge 145:64910690c574 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
Kojto 122:f9eeca106725 12 *
Kojto 122:f9eeca106725 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 122:f9eeca106725 14 * are permitted provided that the following conditions are met:
Kojto 122:f9eeca106725 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 122:f9eeca106725 16 * this list of conditions and the following disclaimer.
Kojto 122:f9eeca106725 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 122:f9eeca106725 18 * this list of conditions and the following disclaimer in the documentation
Kojto 122:f9eeca106725 19 * and/or other materials provided with the distribution.
Kojto 122:f9eeca106725 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 122:f9eeca106725 21 * may be used to endorse or promote products derived from this software
Kojto 122:f9eeca106725 22 * without specific prior written permission.
Kojto 122:f9eeca106725 23 *
Kojto 122:f9eeca106725 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 122:f9eeca106725 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 122:f9eeca106725 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 122:f9eeca106725 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 122:f9eeca106725 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 122:f9eeca106725 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 122:f9eeca106725 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 122:f9eeca106725 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 122:f9eeca106725 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 122:f9eeca106725 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 122:f9eeca106725 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
Kojto 122:f9eeca106725 37
Kojto 122:f9eeca106725 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 122:f9eeca106725 39 #ifndef __STM32L4xx_HAL_NOR_H
Kojto 122:f9eeca106725 40 #define __STM32L4xx_HAL_NOR_H
Kojto 122:f9eeca106725 41
Kojto 122:f9eeca106725 42 #ifdef __cplusplus
Kojto 122:f9eeca106725 43 extern "C" {
Kojto 122:f9eeca106725 44 #endif
Kojto 122:f9eeca106725 45
AnnaBridge 145:64910690c574 46 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || \
AnnaBridge 145:64910690c574 47 defined(STM32L496xx) || defined(STM32L4A6xx)
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 50 #include "stm32l4xx_ll_fmc.h"
Kojto 122:f9eeca106725 51
Kojto 122:f9eeca106725 52
Kojto 122:f9eeca106725 53 /** @addtogroup STM32L4xx_HAL_Driver
Kojto 122:f9eeca106725 54 * @{
Kojto 122:f9eeca106725 55 */
Kojto 122:f9eeca106725 56
Kojto 122:f9eeca106725 57 /** @addtogroup NOR
Kojto 122:f9eeca106725 58 * @{
Kojto 122:f9eeca106725 59 */
Kojto 122:f9eeca106725 60
Kojto 122:f9eeca106725 61 /** @addtogroup NOR_Private_Constants
Kojto 122:f9eeca106725 62 * @{
Kojto 122:f9eeca106725 63 */
Kojto 122:f9eeca106725 64
Kojto 122:f9eeca106725 65 /* NOR device IDs addresses */
Kojto 122:f9eeca106725 66 #define MC_ADDRESS ((uint16_t)0x0000)
Kojto 122:f9eeca106725 67 #define DEVICE_CODE1_ADDR ((uint16_t)0x0001)
Kojto 122:f9eeca106725 68 #define DEVICE_CODE2_ADDR ((uint16_t)0x000E)
Kojto 122:f9eeca106725 69 #define DEVICE_CODE3_ADDR ((uint16_t)0x000F)
Kojto 122:f9eeca106725 70
Kojto 122:f9eeca106725 71 /* NOR CFI IDs addresses */
Kojto 122:f9eeca106725 72 #define CFI1_ADDRESS ((uint16_t)0x10)
Kojto 122:f9eeca106725 73 #define CFI2_ADDRESS ((uint16_t)0x11)
Kojto 122:f9eeca106725 74 #define CFI3_ADDRESS ((uint16_t)0x12)
Kojto 122:f9eeca106725 75 #define CFI4_ADDRESS ((uint16_t)0x13)
Kojto 122:f9eeca106725 76
Kojto 122:f9eeca106725 77 /* NOR memory data width */
Kojto 122:f9eeca106725 78 #define NOR_MEMORY_8B ((uint8_t)0x0)
Kojto 122:f9eeca106725 79 #define NOR_MEMORY_16B ((uint8_t)0x1)
Kojto 122:f9eeca106725 80
Kojto 122:f9eeca106725 81 /* NOR memory device read/write start address */
Kojto 122:f9eeca106725 82 #define NOR_MEMORY_ADRESS1 FMC_BANK1_1
Kojto 122:f9eeca106725 83 #define NOR_MEMORY_ADRESS2 FMC_BANK1_2
Kojto 122:f9eeca106725 84 #define NOR_MEMORY_ADRESS3 FMC_BANK1_3
Kojto 122:f9eeca106725 85 #define NOR_MEMORY_ADRESS4 FMC_BANK1_4
Kojto 122:f9eeca106725 86
Kojto 122:f9eeca106725 87 /**
Kojto 122:f9eeca106725 88 * @}
Kojto 122:f9eeca106725 89 */
Kojto 122:f9eeca106725 90
Kojto 122:f9eeca106725 91 /** @addtogroup NOR_Private_Macros
Kojto 122:f9eeca106725 92 * @{
Kojto 122:f9eeca106725 93 */
Kojto 122:f9eeca106725 94
Kojto 122:f9eeca106725 95 /**
Kojto 122:f9eeca106725 96 * @brief NOR memory address shifting.
Kojto 122:f9eeca106725 97 * @param __NOR_ADDRESS: NOR base address
Kojto 122:f9eeca106725 98 * @param __NOR_MEMORY_WIDTH_: NOR memory width
Kojto 122:f9eeca106725 99 * @param __ADDRESS__: NOR memory address
Kojto 122:f9eeca106725 100 * @retval NOR shifted address value
Kojto 122:f9eeca106725 101 */
Kojto 122:f9eeca106725 102 #define NOR_ADDR_SHIFT(__NOR_ADDRESS, __NOR_MEMORY_WIDTH_, __ADDRESS__) \
Kojto 122:f9eeca106725 103 ((uint32_t)(((__NOR_MEMORY_WIDTH_) == NOR_MEMORY_16B)? \
Kojto 122:f9eeca106725 104 ((uint32_t)((__NOR_ADDRESS) + (2 * (__ADDRESS__)))): \
Kojto 122:f9eeca106725 105 ((uint32_t)((__NOR_ADDRESS) + (__ADDRESS__)))))
Kojto 122:f9eeca106725 106
Kojto 122:f9eeca106725 107 /**
Kojto 122:f9eeca106725 108 * @brief NOR memory write data to specified address.
Kojto 122:f9eeca106725 109 * @param __ADDRESS__: NOR memory address
Kojto 122:f9eeca106725 110 * @param __DATA__: Data to write
Kojto 122:f9eeca106725 111 * @retval None
Kojto 122:f9eeca106725 112 */
Kojto 122:f9eeca106725 113 #define NOR_WRITE(__ADDRESS__, __DATA__) (*(__IO uint16_t *)((uint32_t)(__ADDRESS__)) = (__DATA__))
Kojto 122:f9eeca106725 114
Kojto 122:f9eeca106725 115 /**
Kojto 122:f9eeca106725 116 * @}
Kojto 122:f9eeca106725 117 */
Kojto 122:f9eeca106725 118
Kojto 122:f9eeca106725 119 /* Exported typedef ----------------------------------------------------------*/
Kojto 122:f9eeca106725 120 /** @defgroup NOR_Exported_Types NOR Exported Types
Kojto 122:f9eeca106725 121 * @{
Kojto 122:f9eeca106725 122 */
Kojto 122:f9eeca106725 123
Kojto 122:f9eeca106725 124 /**
Kojto 122:f9eeca106725 125 * @brief HAL SRAM State structures definition
Kojto 122:f9eeca106725 126 */
Kojto 122:f9eeca106725 127 typedef enum
Kojto 122:f9eeca106725 128 {
Kojto 122:f9eeca106725 129 HAL_NOR_STATE_RESET = 0x00, /*!< NOR not yet initialized or disabled */
Kojto 122:f9eeca106725 130 HAL_NOR_STATE_READY = 0x01, /*!< NOR initialized and ready for use */
Kojto 122:f9eeca106725 131 HAL_NOR_STATE_BUSY = 0x02, /*!< NOR internal processing is ongoing */
Kojto 122:f9eeca106725 132 HAL_NOR_STATE_ERROR = 0x03, /*!< NOR error state */
Kojto 122:f9eeca106725 133 HAL_NOR_STATE_PROTECTED = 0x04 /*!< NOR NORSRAM device write protected */
Kojto 122:f9eeca106725 134 }HAL_NOR_StateTypeDef;
Kojto 122:f9eeca106725 135
Kojto 122:f9eeca106725 136 /**
Kojto 122:f9eeca106725 137 * @brief FMC NOR Status typedef
Kojto 122:f9eeca106725 138 */
Kojto 122:f9eeca106725 139 typedef enum
Kojto 122:f9eeca106725 140 {
Kojto 122:f9eeca106725 141 HAL_NOR_STATUS_SUCCESS = 0,
Kojto 122:f9eeca106725 142 HAL_NOR_STATUS_ONGOING,
Kojto 122:f9eeca106725 143 HAL_NOR_STATUS_ERROR,
Kojto 122:f9eeca106725 144 HAL_NOR_STATUS_TIMEOUT
Kojto 122:f9eeca106725 145 }HAL_NOR_StatusTypeDef;
Kojto 122:f9eeca106725 146
Kojto 122:f9eeca106725 147 /**
Kojto 122:f9eeca106725 148 * @brief FMC NOR ID typedef
Kojto 122:f9eeca106725 149 */
Kojto 122:f9eeca106725 150 typedef struct
Kojto 122:f9eeca106725 151 {
Kojto 122:f9eeca106725 152 uint16_t Manufacturer_Code; /*!< Defines the device's manufacturer code used to identify the memory */
Kojto 122:f9eeca106725 153
Kojto 122:f9eeca106725 154 uint16_t Device_Code1;
Kojto 122:f9eeca106725 155
Kojto 122:f9eeca106725 156 uint16_t Device_Code2;
Kojto 122:f9eeca106725 157
Kojto 122:f9eeca106725 158 uint16_t Device_Code3; /*!< Defines the device's codes used to identify the memory.
Kojto 122:f9eeca106725 159 These codes can be accessed by performing read operations with specific
Kojto 122:f9eeca106725 160 control signals and addresses set.They can also be accessed by issuing
Kojto 122:f9eeca106725 161 an Auto Select command. */
Kojto 122:f9eeca106725 162 }NOR_IDTypeDef;
Kojto 122:f9eeca106725 163
Kojto 122:f9eeca106725 164 /**
Kojto 122:f9eeca106725 165 * @brief FMC NOR CFI typedef
Kojto 122:f9eeca106725 166 */
Kojto 122:f9eeca106725 167 typedef struct
Kojto 122:f9eeca106725 168 {
Kojto 122:f9eeca106725 169 uint16_t CFI_1;
Kojto 122:f9eeca106725 170
Kojto 122:f9eeca106725 171 uint16_t CFI_2;
Kojto 122:f9eeca106725 172
Kojto 122:f9eeca106725 173 uint16_t CFI_3;
Kojto 122:f9eeca106725 174
Kojto 122:f9eeca106725 175 uint16_t CFI_4; /*!< Defines the information stored in the memory's Common flash interface
Kojto 122:f9eeca106725 176 which contains a description of various electrical and timing parameters,
Kojto 122:f9eeca106725 177 density information and functions supported by the memory. */
Kojto 122:f9eeca106725 178 }NOR_CFITypeDef;
Kojto 122:f9eeca106725 179
Kojto 122:f9eeca106725 180 /**
Kojto 122:f9eeca106725 181 * @brief NOR handle Structure definition
Kojto 122:f9eeca106725 182 */
Kojto 122:f9eeca106725 183 typedef struct
Kojto 122:f9eeca106725 184 {
Kojto 122:f9eeca106725 185 FMC_NORSRAM_TypeDef *Instance; /*!< Register base address */
Kojto 122:f9eeca106725 186
Kojto 122:f9eeca106725 187 FMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */
Kojto 122:f9eeca106725 188
Kojto 122:f9eeca106725 189 FMC_NORSRAM_InitTypeDef Init; /*!< NOR device control configuration parameters */
Kojto 122:f9eeca106725 190
Kojto 122:f9eeca106725 191 HAL_LockTypeDef Lock; /*!< NOR locking object */
Kojto 122:f9eeca106725 192
Kojto 122:f9eeca106725 193 __IO HAL_NOR_StateTypeDef State; /*!< NOR device access state */
Kojto 122:f9eeca106725 194
Kojto 122:f9eeca106725 195 }NOR_HandleTypeDef;
Kojto 122:f9eeca106725 196
Kojto 122:f9eeca106725 197 /**
Kojto 122:f9eeca106725 198 * @}
Kojto 122:f9eeca106725 199 */
Kojto 122:f9eeca106725 200
Kojto 122:f9eeca106725 201 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 202 /* Exported macro ------------------------------------------------------------*/
Kojto 122:f9eeca106725 203 /** @defgroup NOR_Exported_Macros NOR Exported Macros
Kojto 122:f9eeca106725 204 * @{
Kojto 122:f9eeca106725 205 */
Kojto 122:f9eeca106725 206
Kojto 122:f9eeca106725 207 /** @brief Reset NOR handle state.
Kojto 122:f9eeca106725 208 * @param __HANDLE__: NOR handle
Kojto 122:f9eeca106725 209 * @retval None
Kojto 122:f9eeca106725 210 */
Kojto 122:f9eeca106725 211 #define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NOR_STATE_RESET)
Kojto 122:f9eeca106725 212
Kojto 122:f9eeca106725 213 /**
Kojto 122:f9eeca106725 214 * @}
Kojto 122:f9eeca106725 215 */
Kojto 122:f9eeca106725 216
Kojto 122:f9eeca106725 217 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 218 /** @addtogroup NOR_Exported_Functions NOR Exported Functions
Kojto 122:f9eeca106725 219 * @{
Kojto 122:f9eeca106725 220 */
Kojto 122:f9eeca106725 221
Kojto 122:f9eeca106725 222 /** @addtogroup NOR_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 122:f9eeca106725 223 * @{
Kojto 122:f9eeca106725 224 */
Kojto 122:f9eeca106725 225
Kojto 122:f9eeca106725 226 /* Initialization/de-initialization functions ********************************/
Kojto 122:f9eeca106725 227 HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming);
Kojto 122:f9eeca106725 228 HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor);
Kojto 122:f9eeca106725 229 void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor);
Kojto 122:f9eeca106725 230 void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor);
Kojto 122:f9eeca106725 231 void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout);
Kojto 122:f9eeca106725 232
Kojto 122:f9eeca106725 233 /**
Kojto 122:f9eeca106725 234 * @}
Kojto 122:f9eeca106725 235 */
Kojto 122:f9eeca106725 236
Kojto 122:f9eeca106725 237 /** @addtogroup NOR_Exported_Functions_Group2 Input and Output functions
Kojto 122:f9eeca106725 238 * @{
Kojto 122:f9eeca106725 239 */
Kojto 122:f9eeca106725 240
Kojto 122:f9eeca106725 241 /* I/O operation functions ***************************************************/
Kojto 122:f9eeca106725 242 HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID);
Kojto 122:f9eeca106725 243 HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor);
Kojto 122:f9eeca106725 244 HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData);
Kojto 122:f9eeca106725 245 HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData);
Kojto 122:f9eeca106725 246
Kojto 122:f9eeca106725 247 HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize);
Kojto 122:f9eeca106725 248 HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize);
Kojto 122:f9eeca106725 249
Kojto 122:f9eeca106725 250 HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address);
Kojto 122:f9eeca106725 251 HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address);
Kojto 122:f9eeca106725 252 HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI);
Kojto 122:f9eeca106725 253
Kojto 122:f9eeca106725 254 /**
Kojto 122:f9eeca106725 255 * @}
Kojto 122:f9eeca106725 256 */
Kojto 122:f9eeca106725 257
Kojto 122:f9eeca106725 258 /** @addtogroup NOR_Exported_Functions_Group3 Peripheral Control functions
Kojto 122:f9eeca106725 259 * @{
Kojto 122:f9eeca106725 260 */
Kojto 122:f9eeca106725 261
Kojto 122:f9eeca106725 262 /* NOR Control functions *****************************************************/
Kojto 122:f9eeca106725 263 HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor);
Kojto 122:f9eeca106725 264 HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor);
Kojto 122:f9eeca106725 265
Kojto 122:f9eeca106725 266 /**
Kojto 122:f9eeca106725 267 * @}
Kojto 122:f9eeca106725 268 */
Kojto 122:f9eeca106725 269
Kojto 122:f9eeca106725 270 /** @addtogroup NOR_Exported_Functions_Group4 Peripheral State functions
Kojto 122:f9eeca106725 271 * @{
Kojto 122:f9eeca106725 272 */
Kojto 122:f9eeca106725 273
Kojto 122:f9eeca106725 274 /* NOR State functions ********************************************************/
Kojto 122:f9eeca106725 275 HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor);
Kojto 122:f9eeca106725 276 HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout);
Kojto 122:f9eeca106725 277
Kojto 122:f9eeca106725 278 /**
Kojto 122:f9eeca106725 279 * @}
Kojto 122:f9eeca106725 280 */
Kojto 122:f9eeca106725 281
Kojto 122:f9eeca106725 282 /**
Kojto 122:f9eeca106725 283 * @}
Kojto 122:f9eeca106725 284 */
Kojto 122:f9eeca106725 285
Kojto 122:f9eeca106725 286 /**
Kojto 122:f9eeca106725 287 * @}
Kojto 122:f9eeca106725 288 */
Kojto 122:f9eeca106725 289
Kojto 122:f9eeca106725 290 /**
Kojto 122:f9eeca106725 291 * @}
Kojto 122:f9eeca106725 292 */
Kojto 122:f9eeca106725 293
AnnaBridge 145:64910690c574 294 #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
AnnaBridge 145:64910690c574 295 /* STM32L496xx || STM32L4A6xx || */
Kojto 122:f9eeca106725 296
Kojto 122:f9eeca106725 297 #ifdef __cplusplus
Kojto 122:f9eeca106725 298 }
Kojto 122:f9eeca106725 299 #endif
Kojto 122:f9eeca106725 300
Kojto 122:f9eeca106725 301 #endif /* __STM32L4xx_HAL_NOR_H */
Kojto 122:f9eeca106725 302
Kojto 122:f9eeca106725 303 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/