]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_STM32F7_STM32756G-EVAL/ST_Library/include/stm32f7xx_hal_flash.h
Update version number ready for V8.2.1 release.
[freertos] / FreeRTOS / Demo / CORTEX_M7_STM32F7_STM32756G-EVAL / ST_Library / include / stm32f7xx_hal_flash.h
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f7xx_hal_flash.h\r
4   * @author  MCD Application Team\r
5   * @version V0.3.0\r
6   * @date    06-March-2015\r
7   * @brief   Header file of FLASH HAL module.\r
8   ******************************************************************************\r
9   * @attention\r
10   *\r
11   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>\r
12   *\r
13   * Redistribution and use in source and binary forms, with or without modification,\r
14   * are permitted provided that the following conditions are met:\r
15   *   1. Redistributions of source code must retain the above copyright notice,\r
16   *      this list of conditions and the following disclaimer.\r
17   *   2. Redistributions in binary form must reproduce the above copyright notice,\r
18   *      this list of conditions and the following disclaimer in the documentation\r
19   *      and/or other materials provided with the distribution.\r
20   *   3. Neither the name of STMicroelectronics nor the names of its contributors\r
21   *      may be used to endorse or promote products derived from this software\r
22   *      without specific prior written permission.\r
23   *\r
24   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
25   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
26   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
27   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
28   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
29   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
30   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
31   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
32   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
33   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
34   *\r
35   ******************************************************************************\r
36   */ \r
37 \r
38 /* Define to prevent recursive inclusion -------------------------------------*/\r
39 #ifndef __STM32F7xx_HAL_FLASH_H\r
40 #define __STM32F7xx_HAL_FLASH_H\r
41 \r
42 #ifdef __cplusplus\r
43  extern "C" {\r
44 #endif\r
45 \r
46 /* Includes ------------------------------------------------------------------*/\r
47 #include "stm32f7xx_hal_def.h"\r
48 \r
49 /** @addtogroup STM32F7xx_HAL_Driver\r
50   * @{\r
51   */\r
52 \r
53 /** @addtogroup FLASH\r
54   * @{\r
55   */ \r
56 \r
57 /* Exported types ------------------------------------------------------------*/ \r
58 /** @defgroup FLASH_Exported_Types FLASH Exported Types\r
59   * @{\r
60   */\r
61  \r
62 /**\r
63   * @brief  FLASH Procedure structure definition\r
64   */\r
65 typedef enum \r
66 {\r
67   FLASH_PROC_NONE = 0, \r
68   FLASH_PROC_SECTERASE,\r
69   FLASH_PROC_MASSERASE,\r
70   FLASH_PROC_PROGRAM\r
71 } FLASH_ProcedureTypeDef;\r
72 \r
73 \r
74 /** \r
75   * @brief  FLASH handle Structure definition  \r
76   */\r
77 typedef struct\r
78 {\r
79   __IO FLASH_ProcedureTypeDef ProcedureOnGoing;   /* Internal variable to indicate which procedure is ongoing or not in IT context */\r
80   \r
81   __IO uint32_t               NbSectorsToErase;   /* Internal variable to save the remaining sectors to erase in IT context        */\r
82   \r
83   __IO uint8_t                VoltageForErase;    /* Internal variable to provide voltage range selected by user in IT context    */\r
84   \r
85   __IO uint32_t               Sector;             /* Internal variable to define the current sector which is erasing               */\r
86   \r
87   __IO uint32_t               Address;            /* Internal variable to save address selected for program                        */\r
88   \r
89   HAL_LockTypeDef             Lock;               /* FLASH locking object                                                          */\r
90 \r
91   __IO uint32_t               ErrorCode;          /* FLASH error code                    */\r
92 \r
93 }FLASH_ProcessTypeDef;\r
94 \r
95 /**\r
96   * @}\r
97   */\r
98 \r
99 /* Exported constants --------------------------------------------------------*/\r
100 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants\r
101   * @{\r
102   */  \r
103 \r
104 /** @defgroup FLASH_Error_Code FLASH Error Code\r
105   * @brief    FLASH Error Code \r
106   * @{\r
107   */ \r
108 #define HAL_FLASH_ERROR_NONE         ((uint32_t)0x00000000)    /*!< No error                      */\r
109 #define HAL_FLASH_ERROR_ERS          ((uint32_t)0x00000002)    /*!< Programming Sequence error    */\r
110 #define HAL_FLASH_ERROR_PGP          ((uint32_t)0x00000004)    /*!< Programming Parallelism error */\r
111 #define HAL_FLASH_ERROR_PGA          ((uint32_t)0x00000008)    /*!< Programming Alignment error   */\r
112 #define HAL_FLASH_ERROR_WRP          ((uint32_t)0x00000010)    /*!< Write protection error        */\r
113 #define HAL_FLASH_ERROR_OPERATION    ((uint32_t)0x00000020)    /*!< Operation Error               */\r
114 /**\r
115   * @}\r
116   */\r
117   \r
118 /** @defgroup FLASH_Type_Program FLASH Type Program\r
119   * @{\r
120   */ \r
121 #define FLASH_TYPEPROGRAM_BYTE        ((uint32_t)0x00)  /*!< Program byte (8-bit) at a specified address           */\r
122 #define FLASH_TYPEPROGRAM_HALFWORD    ((uint32_t)0x01)  /*!< Program a half-word (16-bit) at a specified address   */\r
123 #define FLASH_TYPEPROGRAM_WORD        ((uint32_t)0x02)  /*!< Program a word (32-bit) at a specified address        */\r
124 #define FLASH_TYPEPROGRAM_DOUBLEWORD  ((uint32_t)0x03)  /*!< Program a double word (64-bit) at a specified address */\r
125 /**\r
126   * @}\r
127   */\r
128 \r
129 /** @defgroup FLASH_Flag_definition FLASH Flag definition\r
130   * @brief Flag definition\r
131   * @{\r
132   */ \r
133 #define FLASH_FLAG_EOP                 FLASH_SR_EOP            /*!< FLASH End of Operation flag               */\r
134 #define FLASH_FLAG_OPERR               FLASH_SR_OPERR          /*!< FLASH operation Error flag                */\r
135 #define FLASH_FLAG_WRPERR              FLASH_SR_WRPERR         /*!< FLASH Write protected error flag          */\r
136 #define FLASH_FLAG_PGAERR              FLASH_SR_PGAERR         /*!< FLASH Programming Alignment error flag    */\r
137 #define FLASH_FLAG_PGPERR              FLASH_SR_PGPERR         /*!< FLASH Programming Parallelism error flag  */\r
138 #define FLASH_FLAG_ERSERR              FLASH_SR_ERSERR         /*!< FLASH Erasing Sequence error flag         */\r
139 #define FLASH_FLAG_BSY                 FLASH_SR_BSY            /*!< FLASH Busy flag                           */ \r
140 /**\r
141   * @}\r
142   */\r
143 \r
144 /** @defgroup FLASH_Interrupt_definition FLASH Interrupt definition\r
145   * @brief FLASH Interrupt definition\r
146   * @{\r
147   */\r
148 #define FLASH_IT_EOP                   FLASH_CR_EOPIE          /*!< End of FLASH Operation Interrupt source */\r
149 #define FLASH_IT_ERR                   ((uint32_t)0x02000000)  /*!< Error Interrupt source                  */\r
150 /**\r
151   * @}\r
152   */\r
153 \r
154 /** @defgroup FLASH_Program_Parallelism FLASH Program Parallelism\r
155   * @{\r
156   */\r
157 #define FLASH_PSIZE_BYTE           ((uint32_t)0x00000000)\r
158 #define FLASH_PSIZE_HALF_WORD      ((uint32_t)FLASH_CR_PSIZE_0)\r
159 #define FLASH_PSIZE_WORD           ((uint32_t)FLASH_CR_PSIZE_1)\r
160 #define FLASH_PSIZE_DOUBLE_WORD    ((uint32_t)FLASH_CR_PSIZE)\r
161 #define CR_PSIZE_MASK              ((uint32_t)0xFFFFFCFF)\r
162 /**\r
163   * @}\r
164   */ \r
165 \r
166 /** @defgroup FLASH_Keys FLASH Keys\r
167   * @{\r
168   */ \r
169 #define FLASH_KEY1               ((uint32_t)0x45670123)\r
170 #define FLASH_KEY2               ((uint32_t)0xCDEF89AB)\r
171 #define FLASH_OPT_KEY1           ((uint32_t)0x08192A3B)\r
172 #define FLASH_OPT_KEY2           ((uint32_t)0x4C5D6E7F)\r
173 /**\r
174   * @}\r
175   */\r
176 \r
177 /**\r
178   * @}\r
179   */ \r
180   \r
181 /* Exported macro ------------------------------------------------------------*/\r
182 /** @defgroup FLASH_Exported_Macros FLASH Exported Macros\r
183   * @{\r
184   */\r
185 /**\r
186   * @brief  Set the FLASH Latency.\r
187   * @param  __LATENCY__: FLASH Latency                   \r
188   *         The value of this parameter depend on device used within the same series\r
189   * @retval none\r
190   */\r
191 #define __HAL_FLASH_SET_LATENCY(__LATENCY__) \\r
192                   MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(__LATENCY__))\r
193 \r
194                                   \r
195 /**\r
196   * @brief  Enable the FLASH prefetch buffer.\r
197   * @retval none\r
198   */ \r
199 #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE()  (FLASH->ACR |= FLASH_ACR_PRFTEN)\r
200 \r
201 /**\r
202   * @brief  Disable the FLASH prefetch buffer.\r
203   * @retval none\r
204   */ \r
205 #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE()   (FLASH->ACR &= (~FLASH_ACR_PRFTEN))\r
206 \r
207 /**\r
208   * @brief  Enable the FLASH Adaptive Real-Time memory accelerator.\r
209   * @note   The ART accelerator is available only for flash access on ITCM interface.\r
210   * @retval none\r
211   */ \r
212 #define __HAL_FLASH_ART_ENABLE()  SET_BIT(FLASH->ACR, FLASH_ACR_ARTEN)\r
213 \r
214 /**\r
215   * @brief  Disable the FLASH Adaptive Real-Time memory accelerator.\r
216   * @retval none\r
217   */ \r
218 #define __HAL_FLASH_ART_DISABLE()   CLEAR_BIT(FLASH->ACR, FLASH_ACR_ARTEN)\r
219 \r
220 /**\r
221   * @brief  Resets the FLASH Adaptive Real-Time memory accelerator.\r
222   * @note   This function must be used only when the Adaptive Real-Time memory accelerator\r
223   *         is disabled.  \r
224   * @retval None\r
225   */\r
226 #define __HAL_FLASH_ART_RESET()  (FLASH->ACR |= FLASH_ACR_ARTRST)\r
227 \r
228 /**\r
229   * @brief  Enable the specified FLASH interrupt.\r
230   * @param  __INTERRUPT__ : FLASH interrupt \r
231   *         This parameter can be any combination of the following values:\r
232   *     @arg FLASH_IT_EOP: End of FLASH Operation Interrupt\r
233   *     @arg FLASH_IT_ERR: Error Interrupt    \r
234   * @retval none\r
235   */  \r
236 #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__)  (FLASH->CR |= (__INTERRUPT__))\r
237 \r
238 /**\r
239   * @brief  Disable the specified FLASH interrupt.\r
240   * @param  __INTERRUPT__ : FLASH interrupt \r
241   *         This parameter can be any combination of the following values:\r
242   *     @arg FLASH_IT_EOP: End of FLASH Operation Interrupt\r
243   *     @arg FLASH_IT_ERR: Error Interrupt    \r
244   * @retval none\r
245   */  \r
246 #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__)  (FLASH->CR &= ~(uint32_t)(__INTERRUPT__))\r
247 \r
248 /**\r
249   * @brief  Get the specified FLASH flag status. \r
250   * @param  __FLAG__: specifies the FLASH flag to check.\r
251   *          This parameter can be one of the following values:\r
252   *            @arg FLASH_FLAG_EOP   : FLASH End of Operation flag \r
253   *            @arg FLASH_FLAG_OPERR : FLASH operation Error flag \r
254   *            @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag \r
255   *            @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag\r
256   *            @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag\r
257   *            @arg FLASH_FLAG_ERSERR : FLASH Erasing Sequence error flag \r
258   *            @arg FLASH_FLAG_BSY   : FLASH Busy flag\r
259   * @retval The new state of __FLAG__ (SET or RESET).\r
260   */\r
261 #define __HAL_FLASH_GET_FLAG(__FLAG__)   ((FLASH->SR & (__FLAG__)))\r
262 \r
263 /**\r
264   * @brief  Clear the specified FLASH flag.\r
265   * @param  __FLAG__: specifies the FLASH flags to clear.\r
266   *          This parameter can be any combination of the following values:\r
267   *            @arg FLASH_FLAG_EOP   : FLASH End of Operation flag \r
268   *            @arg FLASH_FLAG_OPERR : FLASH operation Error flag \r
269   *            @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag \r
270   *            @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag \r
271   *            @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag\r
272   *            @arg FLASH_FLAG_ERSERR : FLASH Erasing Sequence error flag    \r
273   * @retval none\r
274   */\r
275 #define __HAL_FLASH_CLEAR_FLAG(__FLAG__)   (FLASH->SR = (__FLAG__))\r
276 /**\r
277   * @}\r
278   */\r
279 \r
280 /* Include FLASH HAL Extension module */\r
281 #include "stm32f7xx_hal_flash_ex.h"\r
282 \r
283 /* Exported functions --------------------------------------------------------*/\r
284 /** @addtogroup FLASH_Exported_Functions\r
285   * @{\r
286   */\r
287 /** @addtogroup FLASH_Exported_Functions_Group1\r
288   * @{\r
289   */\r
290 /* Program operation functions  ***********************************************/\r
291 HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);\r
292 HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);\r
293 /* FLASH IRQ handler method */\r
294 void HAL_FLASH_IRQHandler(void);\r
295 /* Callbacks in non blocking modes */ \r
296 void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);\r
297 void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);\r
298 /**\r
299   * @}\r
300   */\r
301 \r
302 /** @addtogroup FLASH_Exported_Functions_Group2\r
303   * @{\r
304   */\r
305 /* Peripheral Control functions  **********************************************/\r
306 HAL_StatusTypeDef HAL_FLASH_Unlock(void);\r
307 HAL_StatusTypeDef HAL_FLASH_Lock(void);\r
308 HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);\r
309 HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);\r
310 /* Option bytes control */\r
311 HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);\r
312 /**\r
313   * @}\r
314   */\r
315 \r
316 /** @addtogroup FLASH_Exported_Functions_Group3\r
317   * @{\r
318   */\r
319 /* Peripheral State functions  ************************************************/\r
320 uint32_t HAL_FLASH_GetError(void);\r
321 HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);\r
322 /**\r
323   * @}\r
324   */\r
325 \r
326 /**\r
327   * @}\r
328   */\r
329 /* Private types -------------------------------------------------------------*/\r
330 /* Private variables ---------------------------------------------------------*/\r
331 /** @defgroup FLASH_Private_Variables FLASH Private Variables\r
332   * @{\r
333   */\r
334 \r
335 /**\r
336   * @}\r
337   */\r
338 /* Private constants ---------------------------------------------------------*/\r
339 /** @defgroup FLASH_Private_Constants FLASH Private Constants\r
340   * @{\r
341   */\r
342 \r
343 /**\r
344   * @}\r
345   */\r
346 \r
347 /* Private macros ------------------------------------------------------------*/\r
348 /** @defgroup FLASH_Private_Macros FLASH Private Macros\r
349   * @{\r
350   */\r
351 \r
352 /** @defgroup FLASH_IS_FLASH_Definitions FLASH Private macros to check input parameters\r
353   * @{\r
354   */\r
355 #define IS_FLASH_TYPEPROGRAM(VALUE)(((VALUE) == FLASH_TYPEPROGRAM_BYTE) || \\r
356                                     ((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \\r
357                                     ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \\r
358                                     ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD))  \r
359 /**\r
360   * @}\r
361   */\r
362 \r
363 /**\r
364   * @}\r
365   */\r
366 \r
367 /* Private functions ---------------------------------------------------------*/\r
368 /** @defgroup FLASH_Private_Functions FLASH Private Functions\r
369   * @{\r
370   */\r
371 \r
372 /**\r
373   * @}\r
374   */\r
375 \r
376 /**\r
377   * @}\r
378   */ \r
379 \r
380 /**\r
381   * @}\r
382   */\r
383 \r
384 #ifdef __cplusplus\r
385 }\r
386 #endif\r
387 \r
388 #endif /* __STM32F7xx_HAL_FLASH_H */\r
389 \r
390 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r