Rev 56 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 56 | Rev 61 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @brief Header file of NOR HAL module. |
5 | * @brief Header file of NOR HAL module. |
| 6 | ****************************************************************************** |
6 | ****************************************************************************** |
| 7 | * @attention |
7 | * @attention |
| 8 | * |
8 | * |
| 9 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
| 10 | * All rights reserved.</center></h2> |
10 | * All rights reserved.</center></h2> |
| 11 | * |
11 | * |
| 12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
| 13 | * the "License"; You may not use this file except in compliance with the |
13 | * the "License"; You may not use this file except in compliance with the |
| 14 | * License. You may obtain a copy of the License at: |
14 | * License. You may obtain a copy of the License at: |
| 15 | * opensource.org/licenses/BSD-3-Clause |
15 | * opensource.org/licenses/BSD-3-Clause |
| 16 | * |
16 | * |
| 17 | ****************************************************************************** |
17 | ****************************************************************************** |
| 18 | */ |
18 | */ |
| 19 | 19 | ||
| 20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| 21 | #ifndef __STM32L1xx_HAL_NOR_H |
21 | #ifndef STM32L1xx_HAL_NOR_H |
| 22 | #define __STM32L1xx_HAL_NOR_H |
22 | #define STM32L1xx_HAL_NOR_H |
| 23 | 23 | ||
| 24 | #ifdef __cplusplus |
24 | #ifdef __cplusplus |
| 25 | extern "C" { |
25 | extern "C" { |
| 26 | #endif |
26 | #endif |
| 27 | 27 | ||
| - | 28 | #if defined(FSMC_BANK1) |
|
| - | 29 | ||
| 28 | /* Includes ------------------------------------------------------------------*/ |
30 | /* Includes ------------------------------------------------------------------*/ |
| 29 | #include "stm32l1xx_ll_fsmc.h" |
31 | #include "stm32l1xx_ll_fsmc.h" |
| 30 | 32 | ||
| 31 | /** @addtogroup STM32L1xx_HAL_Driver |
33 | /** @addtogroup STM32L1xx_HAL_Driver |
| 32 | * @{ |
34 | * @{ |
| 33 | */ |
35 | */ |
| 34 | 36 | ||
| 35 | #if defined (STM32L151xD) || defined (STM32L152xD) || defined (STM32L162xD) |
- | |
| 36 | /** @addtogroup NOR |
37 | /** @addtogroup NOR |
| 37 | * @{ |
38 | * @{ |
| 38 | */ |
- | |
| 39 | - | ||
| 40 | /** @addtogroup NOR_Private_Constants |
- | |
| 41 | * @{ |
- | |
| 42 | */ |
39 | */ |
| 43 | 40 | ||
| 44 | /* NOR device IDs addresses */ |
- | |
| 45 | #define MC_ADDRESS ((uint16_t)0x0000) |
- | |
| 46 | #define DEVICE_CODE1_ADDR ((uint16_t)0x0001) |
- | |
| 47 | #define DEVICE_CODE2_ADDR ((uint16_t)0x000E) |
- | |
| 48 | #define DEVICE_CODE3_ADDR ((uint16_t)0x000F) |
- | |
| 49 | - | ||
| 50 | /* NOR CFI IDs addresses */ |
- | |
| 51 | #define CFI1_ADDRESS ((uint16_t)0x10) |
- | |
| 52 | #define CFI2_ADDRESS ((uint16_t)0x11) |
- | |
| 53 | #define CFI3_ADDRESS ((uint16_t)0x12) |
- | |
| 54 | #define CFI4_ADDRESS ((uint16_t)0x13) |
- | |
| 55 | - | ||
| 56 | /* NOR operation wait timeout */ |
- | |
| 57 | #define NOR_TMEOUT ((uint16_t)0xFFFF) |
- | |
| 58 | - | ||
| 59 | /* NOR memory data width */ |
- | |
| 60 | #define NOR_MEMORY_8B ((uint8_t)0x0) |
- | |
| 61 | #define NOR_MEMORY_16B ((uint8_t)0x1) |
- | |
| 62 | - | ||
| 63 | /* NOR memory device read/write start address */ |
41 | /* Exported typedef ----------------------------------------------------------*/ |
| 64 | #define NOR_MEMORY_ADRESS1 FSMC_BANK1_1 |
- | |
| 65 | #define NOR_MEMORY_ADRESS2 FSMC_BANK1_2 |
- | |
| 66 | #define NOR_MEMORY_ADRESS3 FSMC_BANK1_3 |
- | |
| 67 | #define NOR_MEMORY_ADRESS4 FSMC_BANK1_4 |
- | |
| 68 | - | ||
| 69 | /** |
- | |
| 70 | * @} |
- | |
| 71 | */ |
- | |
| 72 | - | ||
| 73 | /** @addtogroup NOR_Private_Macros |
42 | /** @defgroup NOR_Exported_Types NOR Exported Types |
| 74 | * @{ |
43 | * @{ |
| 75 | */ |
44 | */ |
| 76 | 45 | ||
| 77 | /** |
46 | /** |
| 78 | * @brief NOR memory address shifting. |
47 | * @brief HAL SRAM State structures definition |
| 79 | * @param __NOR_ADDRESS NOR base address |
- | |
| 80 | * @param __NOR_MEMORY_WIDTH_ NOR memory width |
- | |
| 81 | * @param __ADDRESS__ NOR memory address |
- | |
| 82 | * @retval NOR shifted address value |
- | |
| 83 | */ |
48 | */ |
| 84 | #define NOR_ADDR_SHIFT(__NOR_ADDRESS, __NOR_MEMORY_WIDTH_, __ADDRESS__) \ |
- | |
| 85 | ((uint32_t)(((__NOR_MEMORY_WIDTH_) == NOR_MEMORY_16B)? \ |
- | |
| 86 | ((uint32_t)((__NOR_ADDRESS) + (2 * (__ADDRESS__)))): \ |
- | |
| 87 | ((uint32_t)((__NOR_ADDRESS) + (__ADDRESS__))))) |
- | |
| 88 | - | ||
| 89 | /** |
- | |
| 90 | * @brief NOR memory write data to specified address. |
- | |
| 91 | * @param __ADDRESS__ NOR memory address |
- | |
| 92 | * @param __DATA__ Data to write |
- | |
| 93 | * @retval None |
- | |
| 94 | */ |
- | |
| 95 | #define NOR_WRITE(__ADDRESS__, __DATA__) (*(__IO uint16_t *)((uint32_t)(__ADDRESS__)) = (__DATA__)) |
- | |
| 96 | - | ||
| 97 | /** |
- | |
| 98 | * @} |
- | |
| 99 | */ |
- | |
| 100 | - | ||
| 101 | /* Exported typedef ----------------------------------------------------------*/ |
- | |
| 102 | /** @defgroup NOR_Exported_Types NOR Exported Types |
- | |
| 103 | * @{ |
- | |
| 104 | */ |
- | |
| 105 | - | ||
| 106 | /** |
- | |
| 107 | * @brief HAL SRAM State structures definition |
- | |
| 108 | */ |
- | |
| 109 | typedef enum |
49 | typedef enum |
| 110 | { |
50 | { |
| 111 | HAL_NOR_STATE_RESET = 0x00, /*!< NOR not yet initialized or disabled */ |
51 | HAL_NOR_STATE_RESET = 0x00U, /*!< NOR not yet initialized or disabled */ |
| 112 | HAL_NOR_STATE_READY = 0x01, /*!< NOR initialized and ready for use */ |
52 | HAL_NOR_STATE_READY = 0x01U, /*!< NOR initialized and ready for use */ |
| 113 | HAL_NOR_STATE_BUSY = 0x02, /*!< NOR internal processing is ongoing */ |
53 | HAL_NOR_STATE_BUSY = 0x02U, /*!< NOR internal processing is ongoing */ |
| 114 | HAL_NOR_STATE_ERROR = 0x03, /*!< NOR error state */ |
54 | HAL_NOR_STATE_ERROR = 0x03U, /*!< NOR error state */ |
| 115 | HAL_NOR_STATE_PROTECTED = 0x04 /*!< NOR NORSRAM device write protected */ |
55 | HAL_NOR_STATE_PROTECTED = 0x04U /*!< NOR NORSRAM device write protected */ |
| 116 | }HAL_NOR_StateTypeDef; |
56 | } HAL_NOR_StateTypeDef; |
| 117 | 57 | ||
| 118 | /** |
58 | /** |
| 119 | * @brief FSMC NOR Status typedef |
59 | * @brief FSMC NOR Status typedef |
| 120 | */ |
60 | */ |
| 121 | typedef enum |
61 | typedef enum |
| 122 | { |
62 | { |
| 123 | HAL_NOR_STATUS_SUCCESS = 0, |
63 | HAL_NOR_STATUS_SUCCESS = 0U, |
| 124 | HAL_NOR_STATUS_ONGOING, |
64 | HAL_NOR_STATUS_ONGOING, |
| 125 | HAL_NOR_STATUS_ERROR, |
65 | HAL_NOR_STATUS_ERROR, |
| 126 | HAL_NOR_STATUS_TIMEOUT |
66 | HAL_NOR_STATUS_TIMEOUT |
| 127 | }HAL_NOR_StatusTypeDef; |
67 | } HAL_NOR_StatusTypeDef; |
| 128 | 68 | ||
| 129 | /** |
69 | /** |
| 130 | * @brief FSMC NOR ID typedef |
70 | * @brief FSMC NOR ID typedef |
| 131 | */ |
71 | */ |
| 132 | typedef struct |
72 | typedef struct |
| 133 | { |
73 | { |
| 134 | uint16_t Manufacturer_Code; /*!< Defines the device's manufacturer code used to identify the memory */ |
74 | uint16_t Manufacturer_Code; /*!< Defines the device's manufacturer code used to identify the memory */ |
| 135 | 75 | ||
| 136 | uint16_t Device_Code1; |
76 | uint16_t Device_Code1; |
| 137 | 77 | ||
| 138 | uint16_t Device_Code2; |
78 | uint16_t Device_Code2; |
| 139 | 79 | ||
| 140 | uint16_t Device_Code3; /*!< Defines the device's codes used to identify the memory. |
80 | uint16_t Device_Code3; /*!< Defines the device's codes used to identify the memory. |
| 141 | These codes can be accessed by performing read operations with specific |
81 | These codes can be accessed by performing read operations with specific |
| 142 | control signals and addresses set.They can also be accessed by issuing |
82 | control signals and addresses set.They can also be accessed by issuing |
| 143 | an Auto Select command */ |
83 | an Auto Select command */ |
| 144 | }NOR_IDTypeDef; |
84 | } NOR_IDTypeDef; |
| 145 | 85 | ||
| 146 | /** |
86 | /** |
| 147 | * @brief FSMC NOR CFI typedef |
87 | * @brief FSMC NOR CFI typedef |
| 148 | */ |
88 | */ |
| 149 | typedef struct |
89 | typedef struct |
| 150 | { |
90 | { |
| 151 | /*!< Defines the information stored in the memory's Common flash interface |
91 | /*!< Defines the information stored in the memory's Common flash interface |
| 152 | which contains a description of various electrical and timing parameters, |
92 | which contains a description of various electrical and timing parameters, |
| 153 | density information and functions supported by the memory */ |
93 | density information and functions supported by the memory */ |
| 154 | 94 | ||
| 155 | uint16_t CFI_1; |
95 | uint16_t CFI_1; |
| 156 | 96 | ||
| 157 | uint16_t CFI_2; |
97 | uint16_t CFI_2; |
| 158 | 98 | ||
| 159 | uint16_t CFI_3; |
99 | uint16_t CFI_3; |
| 160 | 100 | ||
| 161 | uint16_t CFI_4; |
101 | uint16_t CFI_4; |
| 162 | }NOR_CFITypeDef; |
102 | } NOR_CFITypeDef; |
| 163 | 103 | ||
| 164 | /** |
104 | /** |
| 165 | * @brief NOR handle Structure definition |
105 | * @brief NOR handle Structure definition |
| 166 | */ |
106 | */ |
| - | 107 | #if (USE_HAL_NOR_REGISTER_CALLBACKS == 1) |
|
| - | 108 | typedef struct __NOR_HandleTypeDef |
|
| - | 109 | #else |
|
| 167 | typedef struct |
110 | typedef struct |
| - | 111 | #endif /* USE_HAL_NOR_REGISTER_CALLBACKS */ |
|
| - | 112 | ||
| 168 | { |
113 | { |
| 169 | FSMC_NORSRAM_TypeDef *Instance; /*!< Register base address */ |
114 | FSMC_NORSRAM_TypeDef *Instance; /*!< Register base address */ |
| 170 | 115 | ||
| 171 | FSMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */ |
116 | FSMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */ |
| 172 | 117 | ||
| 173 | FSMC_NORSRAM_InitTypeDef Init; /*!< NOR device control configuration parameters */ |
118 | FSMC_NORSRAM_InitTypeDef Init; /*!< NOR device control configuration parameters */ |
| - | 119 | ||
| - | 120 | HAL_LockTypeDef Lock; /*!< NOR locking object */ |
|
| 174 | 121 | ||
| 175 | HAL_LockTypeDef Lock; /*!< NOR locking object */ |
- | |
| 176 | - | ||
| 177 | __IO HAL_NOR_StateTypeDef State; /*!< NOR device access state */ |
122 | __IO HAL_NOR_StateTypeDef State; /*!< NOR device access state */ |
| - | 123 | ||
| - | 124 | uint32_t CommandSet; /*!< NOR algorithm command set and control */ |
|
| - | 125 | ||
| - | 126 | #if (USE_HAL_NOR_REGISTER_CALLBACKS == 1) |
|
| - | 127 | void (* MspInitCallback)(struct __NOR_HandleTypeDef *hnor); /*!< NOR Msp Init callback */ |
|
| - | 128 | void (* MspDeInitCallback)(struct __NOR_HandleTypeDef *hnor); /*!< NOR Msp DeInit callback */ |
|
| - | 129 | #endif /* USE_HAL_NOR_REGISTER_CALLBACKS */ |
|
| - | 130 | } NOR_HandleTypeDef; |
|
| - | 131 | ||
| - | 132 | #if (USE_HAL_NOR_REGISTER_CALLBACKS == 1) |
|
| - | 133 | /** |
|
| - | 134 | * @brief HAL NOR Callback ID enumeration definition |
|
| 178 | 135 | */ |
|
| - | 136 | typedef enum |
|
| - | 137 | { |
|
| - | 138 | HAL_NOR_MSP_INIT_CB_ID = 0x00U, /*!< NOR MspInit Callback ID */ |
|
| - | 139 | HAL_NOR_MSP_DEINIT_CB_ID = 0x01U /*!< NOR MspDeInit Callback ID */ |
|
| 179 | }NOR_HandleTypeDef; |
140 | } HAL_NOR_CallbackIDTypeDef; |
| 180 | 141 | ||
| 181 | /** |
142 | /** |
| - | 143 | * @brief HAL NOR Callback pointer definition |
|
| - | 144 | */ |
|
| - | 145 | typedef void (*pNOR_CallbackTypeDef)(NOR_HandleTypeDef *hnor); |
|
| - | 146 | #endif /* USE_HAL_NOR_REGISTER_CALLBACKS */ |
|
| - | 147 | /** |
|
| 182 | * @} |
148 | * @} |
| 183 | */ |
149 | */ |
| 184 | 150 | ||
| 185 | /* Exported constants --------------------------------------------------------*/ |
151 | /* Exported constants --------------------------------------------------------*/ |
| 186 | /* Exported macro ------------------------------------------------------------*/ |
152 | /* Exported macro ------------------------------------------------------------*/ |
| 187 | - | ||
| 188 | /** @defgroup NOR_Exported_macro NOR Exported Macros |
153 | /** @defgroup NOR_Exported_Macros NOR Exported Macros |
| 189 | * @{ |
154 | * @{ |
| 190 | */ |
155 | */ |
| 191 | - | ||
| 192 | /** @brief Reset NOR handle state |
156 | /** @brief Reset NOR handle state |
| 193 | * @param __HANDLE__ NOR handle |
157 | * @param __HANDLE__ specifies the NOR handle. |
| 194 | * @retval None |
158 | * @retval None |
| 195 | */ |
159 | */ |
| - | 160 | #if (USE_HAL_NOR_REGISTER_CALLBACKS == 1) |
|
| - | 161 | #define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) do { \ |
|
| - | 162 | (__HANDLE__)->State = HAL_NOR_STATE_RESET; \ |
|
| - | 163 | (__HANDLE__)->MspInitCallback = NULL; \ |
|
| - | 164 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
|
| - | 165 | } while(0) |
|
| - | 166 | #else |
|
| 196 | #define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NOR_STATE_RESET) |
167 | #define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NOR_STATE_RESET) |
| 197 | - | ||
| - | 168 | #endif /* USE_HAL_NOR_REGISTER_CALLBACKS */ |
|
| 198 | /** |
169 | /** |
| 199 | * @} |
170 | * @} |
| 200 | */ |
171 | */ |
| 201 | 172 | ||
| 202 | /* Exported functions --------------------------------------------------------*/ |
173 | /* Exported functions --------------------------------------------------------*/ |
| 203 | /** @addtogroup NOR_Exported_Functions NOR Exported Functions |
174 | /** @addtogroup NOR_Exported_Functions NOR Exported Functions |
| 204 | * @{ |
175 | * @{ |
| 205 | */ |
176 | */ |
| 206 | 177 | ||
| 207 | /** @addtogroup NOR_Exported_Functions_Group1 |
178 | /** @addtogroup NOR_Exported_Functions_Group1 Initialization and de-initialization functions |
| 208 | * @{ |
179 | * @{ |
| 209 | */ |
180 | */ |
| 210 | 181 | ||
| 211 | /* Initialization/de-initialization functions **********************************/ |
182 | /* Initialization/de-initialization functions ********************************/ |
| 212 | HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FSMC_NORSRAM_TimingTypeDef *Timing, FSMC_NORSRAM_TimingTypeDef *ExtTiming); |
183 | HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FSMC_NORSRAM_TimingTypeDef *Timing, |
| - | 184 | FSMC_NORSRAM_TimingTypeDef *ExtTiming); |
|
| 213 | HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor); |
185 | HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor); |
| 214 | void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor); |
186 | void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor); |
| 215 | void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor); |
187 | void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor); |
| 216 | void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout); |
188 | void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout); |
| 217 | - | ||
| 218 | /** |
189 | /** |
| 219 | * @} |
190 | * @} |
| 220 | */ |
191 | */ |
| 221 | 192 | ||
| 222 | /** @addtogroup NOR_Exported_Functions_Group2 |
193 | /** @addtogroup NOR_Exported_Functions_Group2 Input and Output functions |
| 223 | * @{ |
194 | * @{ |
| 224 | */ |
195 | */ |
| 225 | 196 | ||
| 226 | /* I/O operation functions ***************************************************/ |
197 | /* I/O operation functions ***************************************************/ |
| 227 | HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID); |
198 | HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID); |
| 228 | HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor); |
199 | HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor); |
| 229 | HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData); |
200 | HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData); |
| 230 | HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData); |
201 | HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData); |
| 231 | 202 | ||
| 232 | HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize); |
203 | HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, |
| - | 204 | uint32_t uwBufferSize); |
|
| 233 | HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize); |
205 | HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, |
| - | 206 | uint32_t uwBufferSize); |
|
| 234 | 207 | ||
| 235 | HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address); |
208 | HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address); |
| 236 | HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address); |
209 | HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address); |
| 237 | HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI); |
210 | HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI); |
| 238 | 211 | ||
| - | 212 | #if (USE_HAL_NOR_REGISTER_CALLBACKS == 1) |
|
| - | 213 | /* NOR callback registering/unregistering */ |
|
| - | 214 | HAL_StatusTypeDef HAL_NOR_RegisterCallback(NOR_HandleTypeDef *hnor, HAL_NOR_CallbackIDTypeDef CallbackId, |
|
| - | 215 | pNOR_CallbackTypeDef pCallback); |
|
| - | 216 | HAL_StatusTypeDef HAL_NOR_UnRegisterCallback(NOR_HandleTypeDef *hnor, HAL_NOR_CallbackIDTypeDef CallbackId); |
|
| - | 217 | #endif /* USE_HAL_NOR_REGISTER_CALLBACKS */ |
|
| 239 | /** |
218 | /** |
| 240 | * @} |
219 | * @} |
| 241 | */ |
220 | */ |
| 242 | 221 | ||
| 243 | /** @addtogroup NOR_Exported_Functions_Group3 |
222 | /** @addtogroup NOR_Exported_Functions_Group3 NOR Control functions |
| 244 | * @{ |
223 | * @{ |
| 245 | */ |
224 | */ |
| 246 | 225 | ||
| 247 | /* NOR Control functions *****************************************************/ |
226 | /* NOR Control functions *****************************************************/ |
| 248 | HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor); |
227 | HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor); |
| 249 | HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor); |
228 | HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor); |
| 250 | - | ||
| 251 | /** |
229 | /** |
| 252 | * @} |
230 | * @} |
| 253 | */ |
231 | */ |
| 254 | 232 | ||
| 255 | /** @addtogroup NOR_Exported_Functions_Group4 |
233 | /** @addtogroup NOR_Exported_Functions_Group4 NOR State functions |
| 256 | * @{ |
234 | * @{ |
| 257 | */ |
235 | */ |
| 258 | 236 | ||
| 259 | /* NOR State functions ********************************************************/ |
237 | /* NOR State functions ********************************************************/ |
| 260 | HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor); |
238 | HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor); |
| 261 | HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout); |
239 | HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout); |
| - | 240 | /** |
|
| - | 241 | * @} |
|
| - | 242 | */ |
|
| 262 | 243 | ||
| 263 | /** |
244 | /** |
| 264 | * @} |
245 | * @} |
| 265 | */ |
246 | */ |
| - | 247 | ||
| - | 248 | /* Private types -------------------------------------------------------------*/ |
|
| - | 249 | /* Private variables ---------------------------------------------------------*/ |
|
| - | 250 | /* Private constants ---------------------------------------------------------*/ |
|
| - | 251 | /** @defgroup NOR_Private_Constants NOR Private Constants |
|
| - | 252 | * @{ |
|
| 266 | 253 | */ |
|
| - | 254 | /* NOR device IDs addresses */ |
|
| - | 255 | #define MC_ADDRESS ((uint16_t)0x0000) |
|
| - | 256 | #define DEVICE_CODE1_ADDR ((uint16_t)0x0001) |
|
| - | 257 | #define DEVICE_CODE2_ADDR ((uint16_t)0x000E) |
|
| - | 258 | #define DEVICE_CODE3_ADDR ((uint16_t)0x000F) |
|
| - | 259 | ||
| - | 260 | /* NOR CFI IDs addresses */ |
|
| - | 261 | #define CFI1_ADDRESS ((uint16_t)0x0061) |
|
| - | 262 | #define CFI2_ADDRESS ((uint16_t)0x0062) |
|
| - | 263 | #define CFI3_ADDRESS ((uint16_t)0x0063) |
|
| - | 264 | #define CFI4_ADDRESS ((uint16_t)0x0064) |
|
| - | 265 | ||
| - | 266 | /* NOR operation wait timeout */ |
|
| - | 267 | #define NOR_TMEOUT ((uint16_t)0xFFFF) |
|
| - | 268 | ||
| - | 269 | /* NOR memory data width */ |
|
| - | 270 | #define NOR_MEMORY_8B ((uint8_t)0x00) |
|
| - | 271 | #define NOR_MEMORY_16B ((uint8_t)0x01) |
|
| - | 272 | ||
| - | 273 | /* NOR memory device read/write start address */ |
|
| - | 274 | #define NOR_MEMORY_ADRESS1 (0x60000000U) |
|
| - | 275 | #define NOR_MEMORY_ADRESS2 (0x64000000U) |
|
| - | 276 | #define NOR_MEMORY_ADRESS3 (0x68000000U) |
|
| - | 277 | #define NOR_MEMORY_ADRESS4 (0x6C000000U) |
|
| 267 | /** |
278 | /** |
| 268 | * @} |
279 | * @} |
| 269 | */ |
280 | */ |
| - | 281 | ||
| - | 282 | /* Private macros ------------------------------------------------------------*/ |
|
| - | 283 | /** @defgroup NOR_Private_Macros NOR Private Macros |
|
| - | 284 | * @{ |
|
| 270 | 285 | */ |
|
| - | 286 | /** |
|
| - | 287 | * @brief NOR memory address shifting. |
|
| - | 288 | * @param __NOR_ADDRESS NOR base address |
|
| - | 289 | * @param __NOR_MEMORY_WIDTH_ NOR memory width |
|
| - | 290 | * @param __ADDRESS__ NOR memory address |
|
| - | 291 | * @retval NOR shifted address value |
|
| - | 292 | */ |
|
| - | 293 | #define NOR_ADDR_SHIFT(__NOR_ADDRESS, __NOR_MEMORY_WIDTH_, __ADDRESS__) \ |
|
| - | 294 | ((uint32_t)(((__NOR_MEMORY_WIDTH_) == NOR_MEMORY_16B)? \ |
|
| - | 295 | ((uint32_t)((__NOR_ADDRESS) + (2U * (__ADDRESS__)))): \ |
|
| - | 296 | ((uint32_t)((__NOR_ADDRESS) + (__ADDRESS__))))) |
|
| - | 297 | ||
| - | 298 | /** |
|
| - | 299 | * @brief NOR memory write data to specified address. |
|
| - | 300 | * @param __ADDRESS__ NOR memory address |
|
| - | 301 | * @param __DATA__ Data to write |
|
| - | 302 | * @retval None |
|
| - | 303 | */ |
|
| - | 304 | #define NOR_WRITE(__ADDRESS__, __DATA__) do{ \ |
|
| - | 305 | (*(__IO uint16_t *)((uint32_t)(__ADDRESS__)) = (__DATA__)); \ |
|
| - | 306 | __DSB(); \ |
|
| - | 307 | } while(0) |
|
| 271 | 308 | ||
| 272 | /** |
309 | /** |
| 273 | * @} |
310 | * @} |
| 274 | */ |
311 | */ |
| 275 | 312 | ||
| - | 313 | /** |
|
| 276 | #endif /* STM32L151xD || STM32L152xD || STM32L162xD */ |
314 | * @} |
| - | 315 | */ |
|
| 277 | 316 | ||
| 278 | /** |
317 | /** |
| 279 | * @} |
318 | * @} |
| 280 | */ |
319 | */ |
| 281 | 320 | ||
| - | 321 | #endif /* FSMC_BANK1 */ |
|
| - | 322 | ||
| 282 | #ifdef __cplusplus |
323 | #ifdef __cplusplus |
| 283 | } |
324 | } |
| 284 | #endif |
325 | #endif |
| 285 | 326 | ||
| 286 | #endif /* __STM32L1xx_HAL_NOR_H */ |
327 | #endif /* STM32L1xx_HAL_NOR_H */ |
| 287 | 328 | ||
| 288 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
329 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |