Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /** |
2 | ****************************************************************************** |
||
3 | * @file stm32f0xx_hal_flash.h |
||
4 | * @author MCD Application Team |
||
5 | * @brief Header file of Flash HAL module. |
||
6 | ****************************************************************************** |
||
7 | * @attention |
||
8 | * |
||
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
||
10 | * All rights reserved.</center></h2> |
||
11 | * |
||
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 |
||
14 | * License. You may obtain a copy of the License at: |
||
15 | * opensource.org/licenses/BSD-3-Clause |
||
16 | * |
||
17 | ****************************************************************************** |
||
18 | */ |
||
19 | |||
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
21 | #ifndef __STM32F0xx_HAL_FLASH_H |
||
22 | #define __STM32F0xx_HAL_FLASH_H |
||
23 | |||
24 | #ifdef __cplusplus |
||
25 | extern "C" { |
||
26 | #endif |
||
27 | |||
28 | /* Includes ------------------------------------------------------------------*/ |
||
29 | #include "stm32f0xx_hal_def.h" |
||
30 | |||
31 | /** @addtogroup STM32F0xx_HAL_Driver |
||
32 | * @{ |
||
33 | */ |
||
34 | |||
35 | /** @addtogroup FLASH |
||
36 | * @{ |
||
37 | */ |
||
38 | |||
39 | /** @addtogroup FLASH_Private_Constants |
||
40 | * @{ |
||
41 | */ |
||
42 | #define FLASH_TIMEOUT_VALUE (50000U) /* 50 s */ |
||
43 | /** |
||
44 | * @} |
||
45 | */ |
||
46 | |||
47 | /** @addtogroup FLASH_Private_Macros |
||
48 | * @{ |
||
49 | */ |
||
50 | |||
51 | #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \ |
||
52 | ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \ |
||
53 | ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD)) |
||
54 | |||
55 | #define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \ |
||
56 | ((__LATENCY__) == FLASH_LATENCY_1)) |
||
57 | |||
58 | /** |
||
59 | * @} |
||
60 | */ |
||
61 | |||
62 | /* Exported types ------------------------------------------------------------*/ |
||
63 | /** @defgroup FLASH_Exported_Types FLASH Exported Types |
||
64 | * @{ |
||
65 | */ |
||
66 | |||
67 | /** |
||
68 | * @brief FLASH Procedure structure definition |
||
69 | */ |
||
70 | typedef enum |
||
71 | { |
||
72 | FLASH_PROC_NONE = 0U, |
||
73 | FLASH_PROC_PAGEERASE = 1U, |
||
74 | FLASH_PROC_MASSERASE = 2U, |
||
75 | FLASH_PROC_PROGRAMHALFWORD = 3U, |
||
76 | FLASH_PROC_PROGRAMWORD = 4U, |
||
77 | FLASH_PROC_PROGRAMDOUBLEWORD = 5U |
||
78 | } FLASH_ProcedureTypeDef; |
||
79 | |||
80 | /** |
||
81 | * @brief FLASH handle Structure definition |
||
82 | */ |
||
83 | typedef struct |
||
84 | { |
||
85 | __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */ |
||
86 | |||
87 | __IO uint32_t DataRemaining; /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */ |
||
88 | |||
89 | __IO uint32_t Address; /*!< Internal variable to save address selected for program or erase */ |
||
90 | |||
91 | __IO uint64_t Data; /*!< Internal variable to save data to be programmed */ |
||
92 | |||
93 | HAL_LockTypeDef Lock; /*!< FLASH locking object */ |
||
94 | |||
95 | __IO uint32_t ErrorCode; /*!< FLASH error code |
||
96 | This parameter can be a value of @ref FLASH_Error_Codes */ |
||
97 | } FLASH_ProcessTypeDef; |
||
98 | |||
99 | /** |
||
100 | * @} |
||
101 | */ |
||
102 | |||
103 | /* Exported constants --------------------------------------------------------*/ |
||
104 | /** @defgroup FLASH_Exported_Constants FLASH Exported Constants |
||
105 | * @{ |
||
106 | */ |
||
107 | |||
108 | /** @defgroup FLASH_Error_Codes FLASH Error Codes |
||
109 | * @{ |
||
110 | */ |
||
111 | |||
112 | #define HAL_FLASH_ERROR_NONE 0x00U /*!< No error */ |
||
113 | #define HAL_FLASH_ERROR_PROG 0x01U /*!< Programming error */ |
||
114 | #define HAL_FLASH_ERROR_WRP 0x02U /*!< Write protection error */ |
||
115 | |||
116 | /** |
||
117 | * @} |
||
118 | */ |
||
119 | |||
120 | /** @defgroup FLASH_Type_Program FLASH Type Program |
||
121 | * @{ |
||
122 | */ |
||
123 | #define FLASH_TYPEPROGRAM_HALFWORD (0x01U) /*!<Program a half-word (16-bit) at a specified address.*/ |
||
124 | #define FLASH_TYPEPROGRAM_WORD (0x02U) /*!<Program a word (32-bit) at a specified address.*/ |
||
125 | #define FLASH_TYPEPROGRAM_DOUBLEWORD (0x03U) /*!<Program a double word (64-bit) at a specified address*/ |
||
126 | |||
127 | /** |
||
128 | * @} |
||
129 | */ |
||
130 | |||
131 | /** @defgroup FLASH_Latency FLASH Latency |
||
132 | * @{ |
||
133 | */ |
||
134 | #define FLASH_LATENCY_0 (0x00000000U) /*!< FLASH Zero Latency cycle */ |
||
135 | #define FLASH_LATENCY_1 FLASH_ACR_LATENCY /*!< FLASH One Latency cycle */ |
||
136 | |||
137 | /** |
||
138 | * @} |
||
139 | */ |
||
140 | |||
141 | |||
142 | /** @defgroup FLASH_Flag_definition FLASH Flag definition |
||
143 | * @{ |
||
144 | */ |
||
145 | #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */ |
||
146 | #define FLASH_FLAG_PGERR FLASH_SR_PGERR /*!< FLASH Programming error flag */ |
||
147 | #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */ |
||
148 | #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Operation flag */ |
||
149 | /** |
||
150 | * @} |
||
151 | */ |
||
152 | |||
153 | /** @defgroup FLASH_Interrupt_definition FLASH Interrupt definition |
||
154 | * @{ |
||
155 | */ |
||
156 | #define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */ |
||
157 | #define FLASH_IT_ERR FLASH_CR_ERRIE /*!< Error Interrupt source */ |
||
158 | /** |
||
159 | * @} |
||
160 | */ |
||
161 | |||
162 | /** |
||
163 | * @} |
||
164 | */ |
||
165 | |||
166 | /* Exported macro ------------------------------------------------------------*/ |
||
167 | |||
168 | /** @defgroup FLASH_Exported_Macros FLASH Exported Macros |
||
169 | * @brief macros to control FLASH features |
||
170 | * @{ |
||
171 | */ |
||
172 | |||
173 | |||
174 | /** @defgroup FLASH_EM_Latency FLASH Latency |
||
175 | * @brief macros to handle FLASH Latency |
||
176 | * @{ |
||
177 | */ |
||
178 | |||
179 | /** |
||
180 | * @brief Set the FLASH Latency. |
||
181 | * @param __LATENCY__ FLASH Latency |
||
182 | * The value of this parameter depend on device used within the same series |
||
183 | * @retval None |
||
184 | */ |
||
185 | #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__)) |
||
186 | |||
187 | |||
188 | /** |
||
189 | * @brief Get the FLASH Latency. |
||
190 | * @retval FLASH Latency |
||
191 | * The value of this parameter depend on device used within the same series |
||
192 | */ |
||
193 | #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)) |
||
194 | |||
195 | /** |
||
196 | * @} |
||
197 | */ |
||
198 | |||
199 | /** @defgroup FLASH_Prefetch FLASH Prefetch |
||
200 | * @brief macros to handle FLASH Prefetch buffer |
||
201 | * @{ |
||
202 | */ |
||
203 | /** |
||
204 | * @brief Enable the FLASH prefetch buffer. |
||
205 | * @retval None |
||
206 | */ |
||
207 | #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTBE) |
||
208 | |||
209 | /** |
||
210 | * @brief Disable the FLASH prefetch buffer. |
||
211 | * @retval None |
||
212 | */ |
||
213 | #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTBE)) |
||
214 | |||
215 | /** |
||
216 | * @} |
||
217 | */ |
||
218 | |||
219 | /** @defgroup FLASH_Interrupt FLASH Interrupts |
||
220 | * @brief macros to handle FLASH interrupts |
||
221 | * @{ |
||
222 | */ |
||
223 | |||
224 | /** |
||
225 | * @brief Enable the specified FLASH interrupt. |
||
226 | * @param __INTERRUPT__ FLASH interrupt |
||
227 | * This parameter can be any combination of the following values: |
||
228 | * @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt |
||
229 | * @arg @ref FLASH_IT_ERR Error Interrupt |
||
230 | * @retval none |
||
231 | */ |
||
232 | #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) SET_BIT((FLASH->CR), (__INTERRUPT__)) |
||
233 | |||
234 | /** |
||
235 | * @brief Disable the specified FLASH interrupt. |
||
236 | * @param __INTERRUPT__ FLASH interrupt |
||
237 | * This parameter can be any combination of the following values: |
||
238 | * @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt |
||
239 | * @arg @ref FLASH_IT_ERR Error Interrupt |
||
240 | * @retval none |
||
241 | */ |
||
242 | #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) CLEAR_BIT((FLASH->CR), (uint32_t)(__INTERRUPT__)) |
||
243 | |||
244 | /** |
||
245 | * @brief Get the specified FLASH flag status. |
||
246 | * @param __FLAG__ specifies the FLASH flag to check. |
||
247 | * This parameter can be one of the following values: |
||
248 | * @arg @ref FLASH_FLAG_BSY FLASH Busy flag |
||
249 | * @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag |
||
250 | * @arg @ref FLASH_FLAG_WRPERR FLASH Write protected error flag |
||
251 | * @arg @ref FLASH_FLAG_PGERR FLASH Programming error flag |
||
252 | * @retval The new state of __FLAG__ (SET or RESET). |
||
253 | */ |
||
254 | #define __HAL_FLASH_GET_FLAG(__FLAG__) (((FLASH->SR) & (__FLAG__)) == (__FLAG__)) |
||
255 | |||
256 | /** |
||
257 | * @brief Clear the specified FLASH flag. |
||
258 | * @param __FLAG__ specifies the FLASH flags to clear. |
||
259 | * This parameter can be any combination of the following values: |
||
260 | * @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag |
||
261 | * @arg @ref FLASH_FLAG_WRPERR FLASH Write protected error flag |
||
262 | * @arg @ref FLASH_FLAG_PGERR FLASH Programming error flag |
||
263 | * @retval none |
||
264 | */ |
||
265 | #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) ((FLASH->SR) = (__FLAG__)) |
||
266 | |||
267 | /** |
||
268 | * @} |
||
269 | */ |
||
270 | |||
271 | /** |
||
272 | * @} |
||
273 | */ |
||
274 | |||
275 | /* Include FLASH HAL Extended module */ |
||
276 | #include "stm32f0xx_hal_flash_ex.h" |
||
277 | |||
278 | /* Exported functions --------------------------------------------------------*/ |
||
279 | /** @addtogroup FLASH_Exported_Functions |
||
280 | * @{ |
||
281 | */ |
||
282 | |||
283 | /** @addtogroup FLASH_Exported_Functions_Group1 |
||
284 | * @{ |
||
285 | */ |
||
286 | /* IO operation functions *****************************************************/ |
||
287 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); |
||
288 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); |
||
289 | |||
290 | /* FLASH IRQ handler function */ |
||
291 | void HAL_FLASH_IRQHandler(void); |
||
292 | /* Callbacks in non blocking modes */ |
||
293 | void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); |
||
294 | void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); |
||
295 | |||
296 | /** |
||
297 | * @} |
||
298 | */ |
||
299 | |||
300 | /** @addtogroup FLASH_Exported_Functions_Group2 |
||
301 | * @{ |
||
302 | */ |
||
303 | /* Peripheral Control functions ***********************************************/ |
||
304 | HAL_StatusTypeDef HAL_FLASH_Unlock(void); |
||
305 | HAL_StatusTypeDef HAL_FLASH_Lock(void); |
||
306 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void); |
||
307 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void); |
||
308 | HAL_StatusTypeDef HAL_FLASH_OB_Launch(void); |
||
309 | |||
310 | /** |
||
311 | * @} |
||
312 | */ |
||
313 | |||
314 | /** @addtogroup FLASH_Exported_Functions_Group3 |
||
315 | * @{ |
||
316 | */ |
||
317 | /* Peripheral State and Error functions ***************************************/ |
||
318 | uint32_t HAL_FLASH_GetError(void); |
||
319 | |||
320 | /** |
||
321 | * @} |
||
322 | */ |
||
323 | |||
324 | /** |
||
325 | * @} |
||
326 | */ |
||
327 | |||
328 | /* Private function -------------------------------------------------*/ |
||
329 | /** @addtogroup FLASH_Private_Functions |
||
330 | * @{ |
||
331 | */ |
||
332 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); |
||
333 | |||
334 | /** |
||
335 | * @} |
||
336 | */ |
||
337 | |||
338 | /** |
||
339 | * @} |
||
340 | */ |
||
341 | |||
342 | /** |
||
343 | * @} |
||
344 | */ |
||
345 | |||
346 | #ifdef __cplusplus |
||
347 | } |
||
348 | #endif |
||
349 | |||
350 | #endif /* __STM32F0xx_HAL_FLASH_H */ |
||
351 | |||
352 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||
353 |