]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_STM32L4_Discovery_Keil_STM32Cube/ST_Code/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash.h
Make vSetupTimerInterrupt weak in the RVDS M4 MPU port to give the
[freertos] / FreeRTOS / Demo / CORTEX_MPU_STM32L4_Discovery_Keil_STM32Cube / ST_Code / Drivers / STM32L4xx_HAL_Driver / Inc / stm32l4xx_hal_flash.h
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l4xx_hal_flash.h\r
4   * @author  MCD Application Team\r
5   * @brief   Header file of FLASH HAL module.\r
6   ******************************************************************************\r
7   * @attention\r
8   *\r
9   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.\r
10   * All rights reserved.</center></h2>\r
11   *\r
12   * This software component is licensed by ST under BSD 3-Clause license,\r
13   * the "License"; You may not use this file except in compliance with the\r
14   * License. You may obtain a copy of the License at:\r
15   *                       opensource.org/licenses/BSD-3-Clause\r
16   *\r
17   ******************************************************************************\r
18   */\r
19 \r
20 /* Define to prevent recursive inclusion -------------------------------------*/\r
21 #ifndef __STM32L4xx_HAL_FLASH_H\r
22 #define __STM32L4xx_HAL_FLASH_H\r
23 \r
24 #ifdef __cplusplus\r
25  extern "C" {\r
26 #endif\r
27 \r
28 /* Includes ------------------------------------------------------------------*/\r
29 #include "stm32l4xx_hal_def.h"\r
30 \r
31 /** @addtogroup STM32L4xx_HAL_Driver\r
32   * @{\r
33   */\r
34 \r
35 /** @addtogroup FLASH\r
36   * @{\r
37   */\r
38 \r
39 /* Exported types ------------------------------------------------------------*/\r
40 /** @defgroup FLASH_Exported_Types FLASH Exported Types\r
41   * @{\r
42   */\r
43 \r
44 /**\r
45   * @brief  FLASH Erase structure definition\r
46   */\r
47 typedef struct\r
48 {\r
49   uint32_t TypeErase;   /*!< Mass erase or page erase.\r
50                              This parameter can be a value of @ref FLASH_Type_Erase */\r
51   uint32_t Banks;       /*!< Select bank to erase.\r
52                              This parameter must be a value of @ref FLASH_Banks\r
53                              (FLASH_BANK_BOTH should be used only for mass erase) */\r
54   uint32_t Page;        /*!< Initial Flash page to erase when page erase is disabled\r
55                              This parameter must be a value between 0 and (max number of pages in the bank - 1)\r
56                              (eg : 255 for 1MB dual bank) */\r
57   uint32_t NbPages;     /*!< Number of pages to be erased.\r
58                              This parameter must be a value between 1 and (max number of pages in the bank - value of initial page)*/\r
59 } FLASH_EraseInitTypeDef;\r
60 \r
61 /**\r
62   * @brief  FLASH Option Bytes Program structure definition\r
63   */\r
64 typedef struct\r
65 {\r
66   uint32_t OptionType;     /*!< Option byte to be configured.\r
67                                 This parameter can be a combination of the values of @ref FLASH_OB_Type */\r
68   uint32_t WRPArea;        /*!< Write protection area to be programmed (used for OPTIONBYTE_WRP).\r
69                                 Only one WRP area could be programmed at the same time.\r
70                                 This parameter can be value of @ref FLASH_OB_WRP_Area */\r
71   uint32_t WRPStartOffset; /*!< Write protection start offset (used for OPTIONBYTE_WRP).\r
72                                 This parameter must be a value between 0 and (max number of pages in the bank - 1)\r
73                                 (eg : 25 for 1MB dual bank) */\r
74   uint32_t WRPEndOffset;   /*!< Write protection end offset (used for OPTIONBYTE_WRP).\r
75                                 This parameter must be a value between WRPStartOffset and (max number of pages in the bank - 1) */\r
76   uint32_t RDPLevel;       /*!< Set the read protection level.. (used for OPTIONBYTE_RDP).\r
77                                 This parameter can be a value of @ref FLASH_OB_Read_Protection */\r
78   uint32_t USERType;       /*!< User option byte(s) to be configured (used for OPTIONBYTE_USER).\r
79                                 This parameter can be a combination of @ref FLASH_OB_USER_Type */\r
80   uint32_t USERConfig;     /*!< Value of the user option byte (used for OPTIONBYTE_USER).\r
81                                 This parameter can be a combination of @ref FLASH_OB_USER_BOR_LEVEL,\r
82                                 @ref FLASH_OB_USER_nRST_STOP, @ref FLASH_OB_USER_nRST_STANDBY,\r
83                                 @ref FLASH_OB_USER_nRST_SHUTDOWN, @ref FLASH_OB_USER_IWDG_SW,\r
84                                 @ref FLASH_OB_USER_IWDG_STOP, @ref FLASH_OB_USER_IWDG_STANDBY,\r
85                                 @ref FLASH_OB_USER_WWDG_SW, @ref FLASH_OB_USER_BFB2,\r
86                                 @ref FLASH_OB_USER_DUALBANK, @ref FLASH_OB_USER_nBOOT1,\r
87                                 @ref FLASH_OB_USER_SRAM2_PE and @ref FLASH_OB_USER_SRAM2_RST */\r
88   uint32_t PCROPConfig;    /*!< Configuration of the PCROP (used for OPTIONBYTE_PCROP).\r
89                                 This parameter must be a combination of @ref FLASH_Banks (except FLASH_BANK_BOTH)\r
90                                 and @ref FLASH_OB_PCROP_RDP */\r
91   uint32_t PCROPStartAddr; /*!< PCROP Start address (used for OPTIONBYTE_PCROP).\r
92                                 This parameter must be a value between begin and end of bank\r
93                                 => Be careful of the bank swapping for the address */\r
94   uint32_t PCROPEndAddr;   /*!< PCROP End address (used for OPTIONBYTE_PCROP).\r
95                                 This parameter must be a value between PCROP Start address and end of bank */\r
96 } FLASH_OBProgramInitTypeDef;\r
97 \r
98 /**\r
99   * @brief  FLASH Procedure structure definition\r
100   */\r
101 typedef enum\r
102 {\r
103   FLASH_PROC_NONE = 0,\r
104   FLASH_PROC_PAGE_ERASE,\r
105   FLASH_PROC_MASS_ERASE,\r
106   FLASH_PROC_PROGRAM,\r
107   FLASH_PROC_PROGRAM_LAST\r
108 } FLASH_ProcedureTypeDef;\r
109 \r
110 /**\r
111   * @brief  FLASH Cache structure definition\r
112   */\r
113 typedef enum\r
114 {\r
115   FLASH_CACHE_DISABLED = 0,\r
116   FLASH_CACHE_ICACHE_ENABLED,\r
117   FLASH_CACHE_DCACHE_ENABLED,\r
118   FLASH_CACHE_ICACHE_DCACHE_ENABLED\r
119 } FLASH_CacheTypeDef;\r
120 \r
121 /**\r
122   * @brief  FLASH handle Structure definition\r
123   */\r
124 typedef struct\r
125 {\r
126   HAL_LockTypeDef             Lock;              /* FLASH locking object */\r
127   __IO uint32_t               ErrorCode;         /* FLASH error code */\r
128   __IO FLASH_ProcedureTypeDef ProcedureOnGoing;  /* Internal variable to indicate which procedure is ongoing or not in IT context */\r
129   __IO uint32_t               Address;           /* Internal variable to save address selected for program in IT context */\r
130   __IO uint32_t               Bank;              /* Internal variable to save current bank selected during erase in IT context */\r
131   __IO uint32_t               Page;              /* Internal variable to define the current page which is erasing in IT context */\r
132   __IO uint32_t               NbPagesToErase;    /* Internal variable to save the remaining pages to erase in IT context */\r
133   __IO FLASH_CacheTypeDef     CacheToReactivate; /* Internal variable to indicate which caches should be reactivated */\r
134 }FLASH_ProcessTypeDef;\r
135 \r
136 /**\r
137   * @}\r
138   */\r
139 \r
140 /* Exported constants --------------------------------------------------------*/\r
141 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants\r
142   * @{\r
143   */\r
144 \r
145 /** @defgroup FLASH_Error FLASH Error\r
146   * @{\r
147   */\r
148 #define HAL_FLASH_ERROR_NONE      0x00000000U\r
149 #define HAL_FLASH_ERROR_OP        FLASH_FLAG_OPERR\r
150 #define HAL_FLASH_ERROR_PROG      FLASH_FLAG_PROGERR\r
151 #define HAL_FLASH_ERROR_WRP       FLASH_FLAG_WRPERR\r
152 #define HAL_FLASH_ERROR_PGA       FLASH_FLAG_PGAERR\r
153 #define HAL_FLASH_ERROR_SIZ       FLASH_FLAG_SIZERR\r
154 #define HAL_FLASH_ERROR_PGS       FLASH_FLAG_PGSERR\r
155 #define HAL_FLASH_ERROR_MIS       FLASH_FLAG_MISERR\r
156 #define HAL_FLASH_ERROR_FAST      FLASH_FLAG_FASTERR\r
157 #define HAL_FLASH_ERROR_RD        FLASH_FLAG_RDERR\r
158 #define HAL_FLASH_ERROR_OPTV      FLASH_FLAG_OPTVERR\r
159 #define HAL_FLASH_ERROR_ECCD      FLASH_FLAG_ECCD\r
160 #if defined (STM32L412xx) || defined (STM32L422xx) || defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || \\r
161     defined (STM32L443xx) || defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \\r
162     defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || \\r
163     defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
164 #define HAL_FLASH_ERROR_PEMPTY    FLASH_FLAG_PEMPTY\r
165 #endif\r
166 /**\r
167   * @}\r
168   */\r
169 \r
170 /** @defgroup FLASH_Type_Erase FLASH Erase Type\r
171   * @{\r
172   */\r
173 #define FLASH_TYPEERASE_PAGES     ((uint32_t)0x00)  /*!<Pages erase only*/\r
174 #define FLASH_TYPEERASE_MASSERASE ((uint32_t)0x01)  /*!<Flash mass erase activation*/\r
175 /**\r
176   * @}\r
177   */\r
178 \r
179 /** @defgroup FLASH_Banks FLASH Banks\r
180   * @{\r
181   */\r
182 #define FLASH_BANK_1              ((uint32_t)0x01)                          /*!< Bank 1   */\r
183 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \\r
184     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
185     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
186 #define FLASH_BANK_2              ((uint32_t)0x02)                          /*!< Bank 2   */\r
187 #define FLASH_BANK_BOTH           ((uint32_t)(FLASH_BANK_1 | FLASH_BANK_2)) /*!< Bank1 and Bank2  */\r
188 #else\r
189 #define FLASH_BANK_BOTH           ((uint32_t)(FLASH_BANK_1))                /*!< Bank 1   */\r
190 #endif\r
191 /**\r
192   * @}\r
193   */\r
194 \r
195 \r
196 /** @defgroup FLASH_Type_Program FLASH Program Type\r
197   * @{\r
198   */\r
199 #define FLASH_TYPEPROGRAM_DOUBLEWORD    ((uint32_t)0x00)  /*!<Program a double-word (64-bit) at a specified address.*/\r
200 #define FLASH_TYPEPROGRAM_FAST          ((uint32_t)0x01)  /*!<Fast program a 32 row double-word (64-bit) at a specified address.\r
201                                                                  And another 32 row double-word (64-bit) will be programmed */\r
202 #define FLASH_TYPEPROGRAM_FAST_AND_LAST ((uint32_t)0x02)  /*!<Fast program a 32 row double-word (64-bit) at a specified address.\r
203                                                                  And this is the last 32 row double-word (64-bit) programmed */\r
204 /**\r
205   * @}\r
206   */\r
207 \r
208 /** @defgroup FLASH_OB_Type FLASH Option Bytes Type\r
209   * @{\r
210   */\r
211 #define OPTIONBYTE_WRP            ((uint32_t)0x01)  /*!< WRP option byte configuration */\r
212 #define OPTIONBYTE_RDP            ((uint32_t)0x02)  /*!< RDP option byte configuration */\r
213 #define OPTIONBYTE_USER           ((uint32_t)0x04)  /*!< USER option byte configuration */\r
214 #define OPTIONBYTE_PCROP          ((uint32_t)0x08)  /*!< PCROP option byte configuration */\r
215 /**\r
216   * @}\r
217   */\r
218 \r
219 /** @defgroup FLASH_OB_WRP_Area FLASH WRP Area\r
220   * @{\r
221   */\r
222 #define OB_WRPAREA_BANK1_AREAA    ((uint32_t)0x00)  /*!< Flash Bank 1 Area A */\r
223 #define OB_WRPAREA_BANK1_AREAB    ((uint32_t)0x01)  /*!< Flash Bank 1 Area B */\r
224 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \\r
225     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
226     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
227 #define OB_WRPAREA_BANK2_AREAA    ((uint32_t)0x02)  /*!< Flash Bank 2 Area A */\r
228 #define OB_WRPAREA_BANK2_AREAB    ((uint32_t)0x04)  /*!< Flash Bank 2 Area B */\r
229 #endif\r
230 /**\r
231   * @}\r
232   */\r
233 \r
234 /** @defgroup FLASH_OB_Read_Protection FLASH Option Bytes Read Protection\r
235   * @{\r
236   */\r
237 #define OB_RDP_LEVEL_0            ((uint32_t)0xAA)\r
238 #define OB_RDP_LEVEL_1            ((uint32_t)0xBB)\r
239 #define OB_RDP_LEVEL_2            ((uint32_t)0xCC) /*!< Warning: When enabling read protection level 2\r
240                                                         it's no more possible to go back to level 1 or 0 */\r
241 /**\r
242   * @}\r
243   */\r
244 \r
245 /** @defgroup FLASH_OB_USER_Type FLASH Option Bytes User Type\r
246   * @{\r
247   */\r
248 #define OB_USER_BOR_LEV           ((uint32_t)0x0001)                   /*!< BOR reset Level */\r
249 #define OB_USER_nRST_STOP         ((uint32_t)0x0002)                   /*!< Reset generated when entering the stop mode */\r
250 #define OB_USER_nRST_STDBY        ((uint32_t)0x0004)                   /*!< Reset generated when entering the standby mode */\r
251 #define OB_USER_IWDG_SW           ((uint32_t)0x0008)                   /*!< Independent watchdog selection */\r
252 #define OB_USER_IWDG_STOP         ((uint32_t)0x0010)                   /*!< Independent watchdog counter freeze in stop mode */\r
253 #define OB_USER_IWDG_STDBY        ((uint32_t)0x0020)                   /*!< Independent watchdog counter freeze in standby mode */\r
254 #define OB_USER_WWDG_SW           ((uint32_t)0x0040)                   /*!< Window watchdog selection */\r
255 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \\r
256     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
257     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
258 #define OB_USER_BFB2              ((uint32_t)0x0080)                   /*!< Dual-bank boot */\r
259 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
260 #define OB_USER_DUALBANK          ((uint32_t)0x0100)                   /*!< Dual-Bank on 1MB or 512kB Flash memory devices */\r
261 #else\r
262 #define OB_USER_DUALBANK          ((uint32_t)0x0100)                   /*!< Dual-Bank on 512KB or 256KB Flash memory devices */\r
263 #endif\r
264 #endif\r
265 #define OB_USER_nBOOT1            ((uint32_t)0x0200)                   /*!< Boot configuration */\r
266 #define OB_USER_SRAM2_PE          ((uint32_t)0x0400)                   /*!< SRAM2 parity check enable */\r
267 #define OB_USER_SRAM2_RST         ((uint32_t)0x0800)                   /*!< SRAM2 Erase when system reset */\r
268 #define OB_USER_nRST_SHDW         ((uint32_t)0x1000)                   /*!< Reset generated when entering the shutdown mode */\r
269 #if defined (STM32L412xx) || defined (STM32L422xx) || defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || \\r
270     defined (STM32L442xx) || defined (STM32L443xx) || defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \\r
271     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
272     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
273 #define OB_USER_nSWBOOT0          ((uint32_t)0x2000)                   /*!< Software BOOT0 */\r
274 #define OB_USER_nBOOT0            ((uint32_t)0x4000)                   /*!< nBOOT0 option bit */\r
275 #endif\r
276 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
277 #define OB_USER_DBANK             ((uint32_t)0x8000)                   /*!< Single bank with 128-bits data or two banks with 64-bits data */\r
278 #endif\r
279 /**\r
280   * @}\r
281   */\r
282 \r
283 /** @defgroup FLASH_OB_USER_BOR_LEVEL FLASH Option Bytes User BOR Level\r
284   * @{\r
285   */\r
286 #define OB_BOR_LEVEL_0            ((uint32_t)FLASH_OPTR_BOR_LEV_0)     /*!< Reset level threshold is around 1.7V */\r
287 #define OB_BOR_LEVEL_1            ((uint32_t)FLASH_OPTR_BOR_LEV_1)     /*!< Reset level threshold is around 2.0V */\r
288 #define OB_BOR_LEVEL_2            ((uint32_t)FLASH_OPTR_BOR_LEV_2)     /*!< Reset level threshold is around 2.2V */\r
289 #define OB_BOR_LEVEL_3            ((uint32_t)FLASH_OPTR_BOR_LEV_3)     /*!< Reset level threshold is around 2.5V */\r
290 #define OB_BOR_LEVEL_4            ((uint32_t)FLASH_OPTR_BOR_LEV_4)     /*!< Reset level threshold is around 2.8V */\r
291 /**\r
292   * @}\r
293   */\r
294 \r
295 /** @defgroup FLASH_OB_USER_nRST_STOP FLASH Option Bytes User Reset On Stop\r
296   * @{\r
297   */\r
298 #define OB_STOP_RST               ((uint32_t)0x0000)                   /*!< Reset generated when entering the stop mode */\r
299 #define OB_STOP_NORST             ((uint32_t)FLASH_OPTR_nRST_STOP)     /*!< No reset generated when entering the stop mode */\r
300 /**\r
301   * @}\r
302   */\r
303 \r
304 /** @defgroup FLASH_OB_USER_nRST_STANDBY FLASH Option Bytes User Reset On Standby\r
305   * @{\r
306   */\r
307 #define OB_STANDBY_RST            ((uint32_t)0x0000)                   /*!< Reset generated when entering the standby mode */\r
308 #define OB_STANDBY_NORST          ((uint32_t)FLASH_OPTR_nRST_STDBY)    /*!< No reset generated when entering the standby mode */\r
309 /**\r
310   * @}\r
311   */\r
312 \r
313 /** @defgroup FLASH_OB_USER_nRST_SHUTDOWN FLASH Option Bytes User Reset On Shutdown\r
314   * @{\r
315   */\r
316 #define OB_SHUTDOWN_RST           ((uint32_t)0x0000)                   /*!< Reset generated when entering the shutdown mode */\r
317 #define OB_SHUTDOWN_NORST         ((uint32_t)FLASH_OPTR_nRST_SHDW)     /*!< No reset generated when entering the shutdown mode */\r
318 /**\r
319   * @}\r
320   */\r
321 \r
322 /** @defgroup FLASH_OB_USER_IWDG_SW FLASH Option Bytes User IWDG Type\r
323   * @{\r
324   */\r
325 #define OB_IWDG_HW                ((uint32_t)0x00000)                  /*!< Hardware independent watchdog */\r
326 #define OB_IWDG_SW                ((uint32_t)FLASH_OPTR_IWDG_SW)       /*!< Software independent watchdog */\r
327 /**\r
328   * @}\r
329   */\r
330 \r
331 /** @defgroup FLASH_OB_USER_IWDG_STOP FLASH Option Bytes User IWDG Mode On Stop\r
332   * @{\r
333   */\r
334 #define OB_IWDG_STOP_FREEZE       ((uint32_t)0x00000)                  /*!< Independent watchdog counter is frozen in Stop mode */\r
335 #define OB_IWDG_STOP_RUN          ((uint32_t)FLASH_OPTR_IWDG_STOP)     /*!< Independent watchdog counter is running in Stop mode */\r
336 /**\r
337   * @}\r
338   */\r
339 \r
340 /** @defgroup FLASH_OB_USER_IWDG_STANDBY FLASH Option Bytes User IWDG Mode On Standby\r
341   * @{\r
342   */\r
343 #define OB_IWDG_STDBY_FREEZE      ((uint32_t)0x00000)                  /*!< Independent watchdog counter is frozen in Standby mode */\r
344 #define OB_IWDG_STDBY_RUN         ((uint32_t)FLASH_OPTR_IWDG_STDBY)    /*!< Independent watchdog counter is running in Standby mode */\r
345 /**\r
346   * @}\r
347   */\r
348 \r
349 /** @defgroup FLASH_OB_USER_WWDG_SW FLASH Option Bytes User WWDG Type\r
350   * @{\r
351   */\r
352 #define OB_WWDG_HW                ((uint32_t)0x00000)                  /*!< Hardware window watchdog */\r
353 #define OB_WWDG_SW                ((uint32_t)FLASH_OPTR_WWDG_SW)       /*!< Software window watchdog */\r
354 /**\r
355   * @}\r
356   */\r
357 \r
358 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \\r
359     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
360     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
361 /** @defgroup FLASH_OB_USER_BFB2 FLASH Option Bytes User BFB2 Mode\r
362   * @{\r
363   */\r
364 #define OB_BFB2_DISABLE           ((uint32_t)0x000000)                 /*!< Dual-bank boot disable */\r
365 #define OB_BFB2_ENABLE            ((uint32_t)FLASH_OPTR_BFB2)          /*!< Dual-bank boot enable */\r
366 /**\r
367   * @}\r
368   */\r
369 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
370 /** @defgroup FLASH_OB_USER_DUALBANK FLASH Option Bytes User Dual-bank Type\r
371   * @{\r
372   */\r
373 #define OB_DUALBANK_SINGLE        ((uint32_t)0x000000)                 /*!< 1 MB/512 kB Single-bank Flash */\r
374 #define OB_DUALBANK_DUAL          ((uint32_t)FLASH_OPTR_DB1M)          /*!< 1 MB/512 kB Dual-bank Flash */\r
375 /**\r
376   * @}\r
377   */\r
378 #else\r
379 /** @defgroup FLASH_OB_USER_DUALBANK FLASH Option Bytes User Dual-bank Type\r
380   * @{\r
381   */\r
382 #define OB_DUALBANK_SINGLE        ((uint32_t)0x000000)                 /*!< 256 KB/512 KB Single-bank Flash */\r
383 #define OB_DUALBANK_DUAL          ((uint32_t)FLASH_OPTR_DUALBANK)      /*!< 256 KB/512 KB Dual-bank Flash */\r
384 /**\r
385   * @}\r
386   */\r
387 #endif\r
388 #endif\r
389 \r
390 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
391 /** @defgroup FLASH_OB_USER_DBANK FLASH Option Bytes User DBANK Type\r
392   * @{\r
393   */\r
394 #define OB_DBANK_128_BITS         ((uint32_t)0x000000)                 /*!< Single-bank with 128-bits data */\r
395 #define OB_DBANK_64_BITS          ((uint32_t)FLASH_OPTR_DBANK)         /*!< Dual-bank with 64-bits data */\r
396 #endif\r
397 /**\r
398   * @}\r
399   */\r
400 /** @defgroup FLASH_OB_USER_nBOOT1 FLASH Option Bytes User BOOT1 Type\r
401   * @{\r
402   */\r
403 #define OB_BOOT1_SRAM             ((uint32_t)0x000000)                 /*!< Embedded SRAM1 is selected as boot space (if BOOT0=1) */\r
404 #define OB_BOOT1_SYSTEM           ((uint32_t)FLASH_OPTR_nBOOT1)        /*!< System memory is selected as boot space (if BOOT0=1) */\r
405 /**\r
406   * @}\r
407   */\r
408 \r
409 /** @defgroup FLASH_OB_USER_SRAM2_PE FLASH Option Bytes User SRAM2 Parity Check Type\r
410   * @{\r
411   */\r
412 #define OB_SRAM2_PARITY_ENABLE    ((uint32_t)0x0000000)                /*!< SRAM2 parity check enable */\r
413 #define OB_SRAM2_PARITY_DISABLE   ((uint32_t)FLASH_OPTR_SRAM2_PE)      /*!< SRAM2 parity check disable */\r
414 /**\r
415   * @}\r
416   */\r
417 \r
418 /** @defgroup FLASH_OB_USER_SRAM2_RST FLASH Option Bytes User SRAM2 Erase On Reset Type\r
419   * @{\r
420   */\r
421 #define OB_SRAM2_RST_ERASE        ((uint32_t)0x0000000)                /*!< SRAM2 erased when a system reset occurs */\r
422 #define OB_SRAM2_RST_NOT_ERASE    ((uint32_t)FLASH_OPTR_SRAM2_RST)     /*!< SRAM2 is not erased when a system reset occurs */\r
423 /**\r
424   * @}\r
425   */\r
426 \r
427 #if defined (STM32L412xx) || defined (STM32L422xx) || defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || \\r
428     defined (STM32L442xx) || defined (STM32L443xx) || defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \\r
429     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
430     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
431 /** @defgroup OB_USER_nSWBOOT0 FLASH Option Bytes User Software BOOT0\r
432   * @{\r
433   */\r
434 #define OB_BOOT0_FROM_OB          ((uint32_t)0x0000000)                /*!< BOOT0 taken from the option bit nBOOT0 */\r
435 #define OB_BOOT0_FROM_PIN         ((uint32_t)FLASH_OPTR_nSWBOOT0)      /*!< BOOT0 taken from PH3/BOOT0 pin */\r
436 /**\r
437   * @}\r
438   */\r
439 \r
440 /** @defgroup OB_USER_nBOOT0 FLASH Option Bytes User nBOOT0 option bit\r
441   * @{\r
442   */\r
443 #define OB_BOOT0_RESET            ((uint32_t)0x0000000)                /*!< nBOOT0 = 0 */\r
444 #define OB_BOOT0_SET              ((uint32_t)FLASH_OPTR_nBOOT0)        /*!< nBOOT0 = 1 */\r
445 /**\r
446   * @}\r
447   */\r
448 #endif\r
449 \r
450 /** @defgroup FLASH_OB_PCROP_RDP FLASH Option Bytes PCROP On RDP Level Type\r
451   * @{\r
452   */\r
453 #define OB_PCROP_RDP_NOT_ERASE    ((uint32_t)0x00000000)               /*!< PCROP area is not erased when the RDP level\r
454                                                                             is decreased from Level 1 to Level 0 */\r
455 #define OB_PCROP_RDP_ERASE        ((uint32_t)FLASH_PCROP1ER_PCROP_RDP) /*!< PCROP area is erased when the RDP level is\r
456                                                                             decreased from Level 1 to Level 0 (full mass erase) */\r
457 /**\r
458   * @}\r
459   */\r
460 \r
461 /** @defgroup FLASH_Latency FLASH Latency\r
462   * @{\r
463   */\r
464 #define FLASH_LATENCY_0           FLASH_ACR_LATENCY_0WS                /*!< FLASH Zero wait state */\r
465 #define FLASH_LATENCY_1           FLASH_ACR_LATENCY_1WS                /*!< FLASH One wait state */\r
466 #define FLASH_LATENCY_2           FLASH_ACR_LATENCY_2WS                /*!< FLASH Two wait states */\r
467 #define FLASH_LATENCY_3           FLASH_ACR_LATENCY_3WS                /*!< FLASH Three wait states */\r
468 #define FLASH_LATENCY_4           FLASH_ACR_LATENCY_4WS                /*!< FLASH Four wait states */\r
469 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
470 #define FLASH_LATENCY_5           FLASH_ACR_LATENCY_5WS                /*!< FLASH Five wait state */\r
471 #define FLASH_LATENCY_6           FLASH_ACR_LATENCY_6WS                /*!< FLASH Six wait state */\r
472 #define FLASH_LATENCY_7           FLASH_ACR_LATENCY_7WS                /*!< FLASH Seven wait states */\r
473 #define FLASH_LATENCY_8           FLASH_ACR_LATENCY_8WS                /*!< FLASH Eight wait states */\r
474 #define FLASH_LATENCY_9           FLASH_ACR_LATENCY_9WS                /*!< FLASH Nine wait states */\r
475 #define FLASH_LATENCY_10          FLASH_ACR_LATENCY_10WS               /*!< FLASH Ten wait state */\r
476 #define FLASH_LATENCY_11          FLASH_ACR_LATENCY_11WS               /*!< FLASH Eleven wait state */\r
477 #define FLASH_LATENCY_12          FLASH_ACR_LATENCY_12WS               /*!< FLASH Twelve wait states */\r
478 #define FLASH_LATENCY_13          FLASH_ACR_LATENCY_13WS               /*!< FLASH Thirteen wait states */\r
479 #define FLASH_LATENCY_14          FLASH_ACR_LATENCY_14WS               /*!< FLASH Fourteen wait states */\r
480 #define FLASH_LATENCY_15          FLASH_ACR_LATENCY_15WS               /*!< FLASH Fifteen wait states */\r
481 #endif\r
482 /**\r
483   * @}\r
484   */\r
485 \r
486 /** @defgroup FLASH_Keys FLASH Keys\r
487   * @{\r
488   */\r
489 #define FLASH_KEY1                0x45670123U                          /*!< Flash key1 */\r
490 #define FLASH_KEY2                0xCDEF89ABU                          /*!< Flash key2: used with FLASH_KEY1\r
491                                                                             to unlock the FLASH registers access */\r
492 \r
493 #define FLASH_PDKEY1              0x04152637U                          /*!< Flash power down key1 */\r
494 #define FLASH_PDKEY2              0xFAFBFCFDU                          /*!< Flash power down key2: used with FLASH_PDKEY1\r
495                                                                             to unlock the RUN_PD bit in FLASH_ACR */\r
496 \r
497 #define FLASH_OPTKEY1             0x08192A3BU                          /*!< Flash option byte key1 */\r
498 #define FLASH_OPTKEY2             0x4C5D6E7FU                          /*!< Flash option byte key2: used with FLASH_OPTKEY1\r
499                                                                             to allow option bytes operations */\r
500 /**\r
501   * @}\r
502   */\r
503 \r
504 /** @defgroup FLASH_Flags FLASH Flags Definition\r
505   * @{\r
506   */\r
507 #define FLASH_FLAG_EOP            FLASH_SR_EOP                         /*!< FLASH End of operation flag */\r
508 #define FLASH_FLAG_OPERR          FLASH_SR_OPERR                       /*!< FLASH Operation error flag */\r
509 #define FLASH_FLAG_PROGERR        FLASH_SR_PROGERR                     /*!< FLASH Programming error flag */\r
510 #define FLASH_FLAG_WRPERR         FLASH_SR_WRPERR                      /*!< FLASH Write protection error flag */\r
511 #define FLASH_FLAG_PGAERR         FLASH_SR_PGAERR                      /*!< FLASH Programming alignment error flag */\r
512 #define FLASH_FLAG_SIZERR         FLASH_SR_SIZERR                      /*!< FLASH Size error flag  */\r
513 #define FLASH_FLAG_PGSERR         FLASH_SR_PGSERR                      /*!< FLASH Programming sequence error flag */\r
514 #define FLASH_FLAG_MISERR         FLASH_SR_MISERR                      /*!< FLASH Fast programming data miss error flag */\r
515 #define FLASH_FLAG_FASTERR        FLASH_SR_FASTERR                     /*!< FLASH Fast programming error flag */\r
516 #define FLASH_FLAG_RDERR          FLASH_SR_RDERR                       /*!< FLASH PCROP read error flag */\r
517 #define FLASH_FLAG_OPTVERR        FLASH_SR_OPTVERR                     /*!< FLASH Option validity error flag  */\r
518 #define FLASH_FLAG_BSY            FLASH_SR_BSY                         /*!< FLASH Busy flag */\r
519 #if defined (STM32L412xx) || defined (STM32L422xx) || defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || \\r
520     defined (STM32L443xx) || defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \\r
521     defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || \\r
522     defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
523 #define FLASH_FLAG_PEMPTY         FLASH_SR_PEMPTY                      /*!< FLASH Program empty */\r
524 #define FLASH_FLAG_SR_ERRORS      (FLASH_FLAG_OPERR   | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \\r
525                                    FLASH_FLAG_PGAERR  | FLASH_FLAG_SIZERR  | FLASH_FLAG_PGSERR | \\r
526                                    FLASH_FLAG_MISERR  | FLASH_FLAG_FASTERR | FLASH_FLAG_RDERR  | \\r
527                                    FLASH_FLAG_OPTVERR | FLASH_FLAG_PEMPTY)\r
528 #else\r
529 #define FLASH_FLAG_SR_ERRORS      (FLASH_FLAG_OPERR   | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \\r
530                                    FLASH_FLAG_PGAERR  | FLASH_FLAG_SIZERR  | FLASH_FLAG_PGSERR | \\r
531                                    FLASH_FLAG_MISERR  | FLASH_FLAG_FASTERR | FLASH_FLAG_RDERR  | \\r
532                                    FLASH_FLAG_OPTVERR)\r
533 #endif\r
534 #define FLASH_FLAG_ECCC           FLASH_ECCR_ECCC                      /*!< FLASH ECC correction */\r
535 #define FLASH_FLAG_ECCD           FLASH_ECCR_ECCD                      /*!< FLASH ECC detection */\r
536 \r
537 #define FLASH_FLAG_ALL_ERRORS     (FLASH_FLAG_OPERR   | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \\r
538                                    FLASH_FLAG_PGAERR  | FLASH_FLAG_SIZERR  | FLASH_FLAG_PGSERR | \\r
539                                    FLASH_FLAG_MISERR  | FLASH_FLAG_FASTERR | FLASH_FLAG_RDERR  | \\r
540                                    FLASH_FLAG_OPTVERR | FLASH_FLAG_ECCD)\r
541 /**\r
542   * @}\r
543   */\r
544 \r
545 /** @defgroup FLASH_Interrupt_definition FLASH Interrupts Definition\r
546   * @brief FLASH Interrupt definition\r
547   * @{\r
548   */\r
549 #define FLASH_IT_EOP              FLASH_CR_EOPIE                       /*!< End of FLASH Operation Interrupt source */\r
550 #define FLASH_IT_OPERR            FLASH_CR_ERRIE                       /*!< Error Interrupt source */\r
551 #define FLASH_IT_RDERR            FLASH_CR_RDERRIE                     /*!< PCROP Read Error Interrupt source*/\r
552 #define FLASH_IT_ECCC             (FLASH_ECCR_ECCIE >> 24)             /*!< ECC Correction Interrupt source */\r
553 /**\r
554   * @}\r
555   */\r
556 \r
557 /* Exported macros -----------------------------------------------------------*/\r
558 /** @defgroup FLASH_Exported_Macros FLASH Exported Macros\r
559  *  @brief macros to control FLASH features\r
560  *  @{\r
561  */\r
562 \r
563 /**\r
564   * @brief  Set the FLASH Latency.\r
565   * @param  __LATENCY__: FLASH Latency\r
566   *         This parameter can be one of the following values :\r
567   *     @arg FLASH_LATENCY_0: FLASH Zero wait state\r
568   *     @arg FLASH_LATENCY_1: FLASH One wait state\r
569   *     @arg FLASH_LATENCY_2: FLASH Two wait states\r
570   *     @arg FLASH_LATENCY_3: FLASH Three wait states\r
571   *     @arg FLASH_LATENCY_4: FLASH Four wait states\r
572   * @retval None\r
573   */\r
574 #define __HAL_FLASH_SET_LATENCY(__LATENCY__)    (MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (__LATENCY__)))\r
575 \r
576 /**\r
577   * @brief  Get the FLASH Latency.\r
578   * @retval FLASH Latency\r
579   *         This parameter can be one of the following values :\r
580   *     @arg FLASH_LATENCY_0: FLASH Zero wait state\r
581   *     @arg FLASH_LATENCY_1: FLASH One wait state\r
582   *     @arg FLASH_LATENCY_2: FLASH Two wait states\r
583   *     @arg FLASH_LATENCY_3: FLASH Three wait states\r
584   *     @arg FLASH_LATENCY_4: FLASH Four wait states\r
585   */\r
586 #define __HAL_FLASH_GET_LATENCY()               READ_BIT(FLASH->ACR, FLASH_ACR_LATENCY)\r
587 \r
588 /**\r
589   * @brief  Enable the FLASH prefetch buffer.\r
590   * @retval None\r
591   */\r
592 #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE()    SET_BIT(FLASH->ACR, FLASH_ACR_PRFTEN)\r
593 \r
594 /**\r
595   * @brief  Disable the FLASH prefetch buffer.\r
596   * @retval None\r
597   */\r
598 #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE()   CLEAR_BIT(FLASH->ACR, FLASH_ACR_PRFTEN)\r
599 \r
600 /**\r
601   * @brief  Enable the FLASH instruction cache.\r
602   * @retval none\r
603   */\r
604 #define __HAL_FLASH_INSTRUCTION_CACHE_ENABLE()  SET_BIT(FLASH->ACR, FLASH_ACR_ICEN)\r
605 \r
606 /**\r
607   * @brief  Disable the FLASH instruction cache.\r
608   * @retval none\r
609   */\r
610 #define __HAL_FLASH_INSTRUCTION_CACHE_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICEN)\r
611 \r
612 /**\r
613   * @brief  Enable the FLASH data cache.\r
614   * @retval none\r
615   */\r
616 #define __HAL_FLASH_DATA_CACHE_ENABLE()         SET_BIT(FLASH->ACR, FLASH_ACR_DCEN)\r
617 \r
618 /**\r
619   * @brief  Disable the FLASH data cache.\r
620   * @retval none\r
621   */\r
622 #define __HAL_FLASH_DATA_CACHE_DISABLE()        CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCEN)\r
623 \r
624 /**\r
625   * @brief  Reset the FLASH instruction Cache.\r
626   * @note   This function must be used only when the Instruction Cache is disabled.\r
627   * @retval None\r
628   */\r
629 #define __HAL_FLASH_INSTRUCTION_CACHE_RESET()   do { SET_BIT(FLASH->ACR, FLASH_ACR_ICRST);   \\r
630                                                      CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICRST); \\r
631                                                    } while (0)\r
632 \r
633 /**\r
634   * @brief  Reset the FLASH data Cache.\r
635   * @note   This function must be used only when the data Cache is disabled.\r
636   * @retval None\r
637   */\r
638 #define __HAL_FLASH_DATA_CACHE_RESET()          do { SET_BIT(FLASH->ACR, FLASH_ACR_DCRST);   \\r
639                                                      CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCRST); \\r
640                                                    } while (0)\r
641 \r
642 /**\r
643   * @brief  Enable the FLASH power down during Low-power run mode.\r
644   * @note   Writing this bit  to 0 this bit, automatically the keys are\r
645   *         loss and a new unlock sequence is necessary to re-write it to 1.\r
646   */\r
647 #define __HAL_FLASH_POWER_DOWN_ENABLE()         do { WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY1); \\r
648                                                      WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY2); \\r
649                                                      SET_BIT(FLASH->ACR, FLASH_ACR_RUN_PD);   \\r
650                                                    } while (0)\r
651 \r
652 /**\r
653   * @brief  Disable the FLASH power down during Low-power run mode.\r
654   * @note   Writing this bit  to 0 this bit, automatically the keys are\r
655   *         loss and a new unlock sequence is necessary to re-write it to 1.\r
656   */\r
657 #define __HAL_FLASH_POWER_DOWN_DISABLE()        do { WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY1); \\r
658                                                      WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY2); \\r
659                                                      CLEAR_BIT(FLASH->ACR, FLASH_ACR_RUN_PD); \\r
660                                                    } while (0)\r
661 \r
662 /**\r
663   * @brief  Enable the FLASH power down during Low-Power sleep mode\r
664   * @retval none\r
665   */\r
666 #define __HAL_FLASH_SLEEP_POWERDOWN_ENABLE()    SET_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)\r
667 \r
668 /**\r
669   * @brief  Disable the FLASH power down during Low-Power sleep mode\r
670   * @retval none\r
671   */\r
672 #define __HAL_FLASH_SLEEP_POWERDOWN_DISABLE()   CLEAR_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)\r
673 \r
674 /**\r
675   * @}\r
676   */\r
677 \r
678 /** @defgroup FLASH_Interrupt FLASH Interrupts Macros\r
679  *  @brief macros to handle FLASH interrupts\r
680  * @{\r
681  */\r
682 \r
683 /**\r
684   * @brief  Enable the specified FLASH interrupt.\r
685   * @param  __INTERRUPT__: FLASH interrupt\r
686   *         This parameter can be any combination of the following values:\r
687   *     @arg FLASH_IT_EOP: End of FLASH Operation Interrupt\r
688   *     @arg FLASH_IT_OPERR: Error Interrupt\r
689   *     @arg FLASH_IT_RDERR: PCROP Read Error Interrupt\r
690   *     @arg FLASH_IT_ECCC: ECC Correction Interrupt\r
691   * @retval none\r
692   */\r
693 #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__)    do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { SET_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\\r
694                                                      if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { SET_BIT(FLASH->CR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\\r
695                                                    } while(0)\r
696 \r
697 /**\r
698   * @brief  Disable the specified FLASH interrupt.\r
699   * @param  __INTERRUPT__: FLASH interrupt\r
700   *         This parameter can be any combination of the following values:\r
701   *     @arg FLASH_IT_EOP: End of FLASH Operation Interrupt\r
702   *     @arg FLASH_IT_OPERR: Error Interrupt\r
703   *     @arg FLASH_IT_RDERR: PCROP Read Error Interrupt\r
704   *     @arg FLASH_IT_ECCC: ECC Correction Interrupt\r
705   * @retval none\r
706   */\r
707 #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__)   do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { CLEAR_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\\r
708                                                      if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { CLEAR_BIT(FLASH->CR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\\r
709                                                    } while(0)\r
710 \r
711 /**\r
712   * @brief  Check whether the specified FLASH flag is set or not.\r
713   * @param  __FLAG__: specifies the FLASH flag to check.\r
714   *   This parameter can be one of the following values:\r
715   *     @arg FLASH_FLAG_EOP: FLASH End of Operation flag\r
716   *     @arg FLASH_FLAG_OPERR: FLASH Operation error flag\r
717   *     @arg FLASH_FLAG_PROGERR: FLASH Programming error flag\r
718   *     @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag\r
719   *     @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag\r
720   *     @arg FLASH_FLAG_SIZERR: FLASH Size error flag\r
721   *     @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag\r
722   *     @arg FLASH_FLAG_MISERR: FLASH Fast programming data miss error flag\r
723   *     @arg FLASH_FLAG_FASTERR: FLASH Fast programming error flag\r
724   *     @arg FLASH_FLAG_RDERR: FLASH PCROP read  error flag\r
725   *     @arg FLASH_FLAG_OPTVERR: FLASH Option validity error flag\r
726   *     @arg FLASH_FLAG_BSY: FLASH write/erase operations in progress flag\r
727   *     @arg FLASH_FLAG_PEMPTY : FLASH Boot from not programmed flash (apply only for STM32L43x/STM32L44x devices)\r
728   *     @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected\r
729   *     @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected\r
730   * @retval The new state of FLASH_FLAG (SET or RESET).\r
731   */\r
732 #define __HAL_FLASH_GET_FLAG(__FLAG__)          ((((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) != 0U) ? \\r
733                                                  (READ_BIT(FLASH->ECCR, (__FLAG__)) == (__FLAG__))          : \\r
734                                                  (READ_BIT(FLASH->SR,   (__FLAG__)) == (__FLAG__)))\r
735 \r
736 /**\r
737   * @brief  Clear the FLASH's pending flags.\r
738   * @param  __FLAG__: specifies the FLASH flags to clear.\r
739   *   This parameter can be any combination of the following values:\r
740   *     @arg FLASH_FLAG_EOP: FLASH End of Operation flag\r
741   *     @arg FLASH_FLAG_OPERR: FLASH Operation error flag\r
742   *     @arg FLASH_FLAG_PROGERR: FLASH Programming error flag\r
743   *     @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag\r
744   *     @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag\r
745   *     @arg FLASH_FLAG_SIZERR: FLASH Size error flag\r
746   *     @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag\r
747   *     @arg FLASH_FLAG_MISERR: FLASH Fast programming data miss error flag\r
748   *     @arg FLASH_FLAG_FASTERR: FLASH Fast programming error flag\r
749   *     @arg FLASH_FLAG_RDERR: FLASH PCROP read  error flag\r
750   *     @arg FLASH_FLAG_OPTVERR: FLASH Option validity error flag\r
751   *     @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected\r
752   *     @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected\r
753   *     @arg FLASH_FLAG_ALL_ERRORS: FLASH All errors flags\r
754   * @retval None\r
755   */\r
756 #define __HAL_FLASH_CLEAR_FLAG(__FLAG__)        do { if(((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) != 0U) { SET_BIT(FLASH->ECCR, ((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD))); }\\r
757                                                      if(((__FLAG__) & ~(FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) != 0U) { WRITE_REG(FLASH->SR, ((__FLAG__) & ~(FLASH_FLAG_ECCC | FLASH_FLAG_ECCD))); }\\r
758                                                    } while(0)\r
759 /**\r
760   * @}\r
761   */\r
762 \r
763 /* Include FLASH HAL Extended module */\r
764 #include "stm32l4xx_hal_flash_ex.h"\r
765 #include "stm32l4xx_hal_flash_ramfunc.h"\r
766 \r
767 /* Exported functions --------------------------------------------------------*/\r
768 /** @addtogroup FLASH_Exported_Functions\r
769   * @{\r
770   */\r
771 \r
772 /* Program operation functions  ***********************************************/\r
773 /** @addtogroup FLASH_Exported_Functions_Group1\r
774   * @{\r
775   */\r
776 HAL_StatusTypeDef  HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);\r
777 HAL_StatusTypeDef  HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);\r
778 /* FLASH IRQ handler method */\r
779 void               HAL_FLASH_IRQHandler(void);\r
780 /* Callbacks in non blocking modes */\r
781 void               HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);\r
782 void               HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);\r
783 /**\r
784   * @}\r
785   */\r
786 \r
787 /* Peripheral Control functions  **********************************************/\r
788 /** @addtogroup FLASH_Exported_Functions_Group2\r
789   * @{\r
790   */\r
791 HAL_StatusTypeDef  HAL_FLASH_Unlock(void);\r
792 HAL_StatusTypeDef  HAL_FLASH_Lock(void);\r
793 /* Option bytes control */\r
794 HAL_StatusTypeDef  HAL_FLASH_OB_Unlock(void);\r
795 HAL_StatusTypeDef  HAL_FLASH_OB_Lock(void);\r
796 HAL_StatusTypeDef  HAL_FLASH_OB_Launch(void);\r
797 /**\r
798   * @}\r
799   */\r
800 \r
801 /* Peripheral State functions  ************************************************/\r
802 /** @addtogroup FLASH_Exported_Functions_Group3\r
803   * @{\r
804   */\r
805 uint32_t HAL_FLASH_GetError(void);\r
806 /**\r
807   * @}\r
808   */\r
809 \r
810 /**\r
811   * @}\r
812   */\r
813 \r
814 /* Private variables ---------------------------------------------------------*/\r
815 /** @addtogroup FLASH_Private_Variables FLASH Private Variables\r
816  * @{\r
817  */\r
818 extern FLASH_ProcessTypeDef pFlash;\r
819 /**\r
820   * @}\r
821   */\r
822 \r
823 /* Private function ----------------------------------------------------------*/\r
824 /** @addtogroup FLASH_Private_Functions FLASH Private Functions\r
825  * @{\r
826  */\r
827 HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);\r
828 /**\r
829   * @}\r
830   */\r
831 \r
832 /* Private constants --------------------------------------------------------*/\r
833 /** @defgroup FLASH_Private_Constants FLASH Private Constants\r
834   * @{\r
835   */\r
836 #define FLASH_SIZE_DATA_REGISTER           ((uint32_t)0x1FFF75E0)\r
837 \r
838 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
839 #define FLASH_SIZE                         (((((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) == 0x0000FFFFU)) ? (0x800U << 10U) : \\r
840                                             (((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) << 10U))\r
841 #elif defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)\r
842 #define FLASH_SIZE                         (((((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) == 0x0000FFFFU)) ? (0x200U << 10U) : \\r
843                                             (((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) << 10U))\r
844 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)\r
845 #define FLASH_SIZE                         (((((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) == 0x0000FFFFU)) ? (0x100U << 10U) : \\r
846                                             (((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) << 10U))\r
847 #elif defined (STM32L412xx) || defined (STM32L422xx)\r
848 #define FLASH_SIZE                         (((((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) == 0x0000FFFFU)) ? (0x80U << 10U) :  \\r
849                                             (((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) << 10U))\r
850 #else\r
851 #define FLASH_SIZE                         (((((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU))== 0x0000FFFFU)) ? (0x400U << 10U) : \\r
852                                             (((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) << 10U))\r
853 #endif\r
854 \r
855 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \\r
856     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
857     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
858 #define FLASH_BANK_SIZE                    (FLASH_SIZE >> 1U)\r
859 #else\r
860 #define FLASH_BANK_SIZE                    (FLASH_SIZE)\r
861 #endif\r
862 \r
863 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
864 #define FLASH_PAGE_SIZE                    ((uint32_t)0x1000)\r
865 #define FLASH_PAGE_SIZE_128_BITS           ((uint32_t)0x2000)\r
866 #else\r
867 #define FLASH_PAGE_SIZE                    ((uint32_t)0x800)\r
868 #endif\r
869 \r
870 #define FLASH_TIMEOUT_VALUE                ((uint32_t)50000)/* 50 s */\r
871 /**\r
872   * @}\r
873   */\r
874 \r
875 /* Private macros ------------------------------------------------------------*/\r
876 /** @defgroup FLASH_Private_Macros FLASH Private Macros\r
877  *  @{\r
878  */\r
879 \r
880 #define IS_FLASH_TYPEERASE(VALUE)          (((VALUE) == FLASH_TYPEERASE_PAGES) || \\r
881                                             ((VALUE) == FLASH_TYPEERASE_MASSERASE))\r
882 \r
883 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \\r
884     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
885     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
886 #define IS_FLASH_BANK(BANK)                (((BANK) == FLASH_BANK_1)  || \\r
887                                             ((BANK) == FLASH_BANK_2)  || \\r
888                                             ((BANK) == FLASH_BANK_BOTH))\r
889 \r
890 #define IS_FLASH_BANK_EXCLUSIVE(BANK)      (((BANK) == FLASH_BANK_1)  || \\r
891                                             ((BANK) == FLASH_BANK_2))\r
892 #else\r
893 #define IS_FLASH_BANK(BANK)                ((BANK) == FLASH_BANK_1)\r
894 \r
895 #define IS_FLASH_BANK_EXCLUSIVE(BANK)      ((BANK) == FLASH_BANK_1)\r
896 #endif\r
897 \r
898 #define IS_FLASH_TYPEPROGRAM(VALUE)        (((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD) || \\r
899                                             ((VALUE) == FLASH_TYPEPROGRAM_FAST) || \\r
900                                             ((VALUE) == FLASH_TYPEPROGRAM_FAST_AND_LAST))\r
901 \r
902 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
903 #define IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS) (((ADDRESS) >= (FLASH_BASE)) && ((ADDRESS) <= (FLASH_BASE+0x1FFFFFU)))\r
904 #else\r
905 #define IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS) (((ADDRESS) >= (FLASH_BASE))         && ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x400U) ? \\r
906                                             ((ADDRESS) <= (FLASH_BASE+0xFFFFFU)) : ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x200U) ? \\r
907                                             ((ADDRESS) <= (FLASH_BASE+0x7FFFFU)) : ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x100U) ? \\r
908                                             ((ADDRESS) <= (FLASH_BASE+0x3FFFFU)) : ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x80U) ? \\r
909                                             ((ADDRESS) <= (FLASH_BASE+0x1FFFFU)) : ((ADDRESS) <= (FLASH_BASE+0xFFFFFU)))))))\r
910 #endif\r
911 \r
912 #define IS_FLASH_OTP_ADDRESS(ADDRESS)      (((ADDRESS) >= 0x1FFF7000U) && ((ADDRESS) <= 0x1FFF73FFU))\r
913 \r
914 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS)  ((IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS)) || (IS_FLASH_OTP_ADDRESS(ADDRESS)))\r
915 \r
916 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
917 #define IS_FLASH_PAGE(PAGE)                ((PAGE) < 256U)\r
918 #elif defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)\r
919 #define IS_FLASH_PAGE(PAGE)                (((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x400U) ? ((PAGE) < 256U) : \\r
920                                             ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x200U) ? ((PAGE) < 128U) : \\r
921                                             ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x100U) ? ((PAGE) < 64U)  : \\r
922                                             ((PAGE) < 256U)))))\r
923 #elif defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)\r
924 #define IS_FLASH_PAGE(PAGE)                (((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x200U) ? ((PAGE) < 256U) : \\r
925                                             ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x100U) ? ((PAGE) < 128U) : \\r
926                                             ((PAGE) < 256U))))\r
927 #else\r
928 #define IS_FLASH_PAGE(PAGE)                (((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x100U) ? ((PAGE) < 128U) : \\r
929                                             ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFFU)) == 0x80U)  ? ((PAGE) < 64U)  : \\r
930                                             ((PAGE) < 128U))))\r
931 #endif\r
932 \r
933 #define IS_OPTIONBYTE(VALUE)               (((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | OPTIONBYTE_PCROP)))\r
934 \r
935 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \\r
936     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
937     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
938 #define IS_OB_WRPAREA(VALUE)               (((VALUE) == OB_WRPAREA_BANK1_AREAA) || ((VALUE) == OB_WRPAREA_BANK1_AREAB) || \\r
939                                             ((VALUE) == OB_WRPAREA_BANK2_AREAA) || ((VALUE) == OB_WRPAREA_BANK2_AREAB))\r
940 #else\r
941 #define IS_OB_WRPAREA(VALUE)               (((VALUE) == OB_WRPAREA_BANK1_AREAA) || ((VALUE) == OB_WRPAREA_BANK1_AREAB))\r
942 #endif\r
943 \r
944 #define IS_OB_RDP_LEVEL(LEVEL)             (((LEVEL) == OB_RDP_LEVEL_0)   ||\\r
945                                             ((LEVEL) == OB_RDP_LEVEL_1)/* ||\\r
946                                             ((LEVEL) == OB_RDP_LEVEL_2)*/)\r
947 \r
948 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
949 #define IS_OB_USER_TYPE(TYPE)              (((TYPE) <= (uint32_t)0xFFFFU) && ((TYPE) != 0U))\r
950 #elif defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)\r
951 #define IS_OB_USER_TYPE(TYPE)              (((TYPE) <= (uint32_t)0x1FFFU) && ((TYPE) != 0U))\r
952 #else\r
953 #define IS_OB_USER_TYPE(TYPE)              (((TYPE) <= (uint32_t)0x7E7FU) && ((TYPE) != 0U) && (((TYPE)&0x0180U) == 0U))\r
954 #endif\r
955 \r
956 #define IS_OB_USER_BOR_LEVEL(LEVEL)        (((LEVEL) == OB_BOR_LEVEL_0) || ((LEVEL) == OB_BOR_LEVEL_1) || \\r
957                                             ((LEVEL) == OB_BOR_LEVEL_2) || ((LEVEL) == OB_BOR_LEVEL_3) || \\r
958                                             ((LEVEL) == OB_BOR_LEVEL_4))\r
959 \r
960 #define IS_OB_USER_STOP(VALUE)             (((VALUE) == OB_STOP_RST) || ((VALUE) == OB_STOP_NORST))\r
961 \r
962 #define IS_OB_USER_STANDBY(VALUE)          (((VALUE) == OB_STANDBY_RST) || ((VALUE) == OB_STANDBY_NORST))\r
963 \r
964 #define IS_OB_USER_SHUTDOWN(VALUE)         (((VALUE) == OB_SHUTDOWN_RST) || ((VALUE) == OB_SHUTDOWN_NORST))\r
965 \r
966 #define IS_OB_USER_IWDG(VALUE)             (((VALUE) == OB_IWDG_HW) || ((VALUE) == OB_IWDG_SW))\r
967 \r
968 #define IS_OB_USER_IWDG_STOP(VALUE)        (((VALUE) == OB_IWDG_STOP_FREEZE) || ((VALUE) == OB_IWDG_STOP_RUN))\r
969 \r
970 #define IS_OB_USER_IWDG_STDBY(VALUE)       (((VALUE) == OB_IWDG_STDBY_FREEZE) || ((VALUE) == OB_IWDG_STDBY_RUN))\r
971 \r
972 #define IS_OB_USER_WWDG(VALUE)             (((VALUE) == OB_WWDG_HW) || ((VALUE) == OB_WWDG_SW))\r
973 \r
974 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \\r
975     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
976     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
977 #define IS_OB_USER_BFB2(VALUE)             (((VALUE) == OB_BFB2_DISABLE) || ((VALUE) == OB_BFB2_ENABLE))\r
978 \r
979 #define IS_OB_USER_DUALBANK(VALUE)         (((VALUE) == OB_DUALBANK_SINGLE) || ((VALUE) == OB_DUALBANK_DUAL))\r
980 #endif\r
981 \r
982 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
983 #define IS_OB_USER_DBANK(VALUE)            (((VALUE) == OB_DBANK_128_BITS) || ((VALUE) == OB_DBANK_64_BITS))\r
984 #endif\r
985 \r
986 #define IS_OB_USER_BOOT1(VALUE)            (((VALUE) == OB_BOOT1_SRAM) || ((VALUE) == OB_BOOT1_SYSTEM))\r
987 \r
988 #define IS_OB_USER_SRAM2_PARITY(VALUE)     (((VALUE) == OB_SRAM2_PARITY_ENABLE) || ((VALUE) == OB_SRAM2_PARITY_DISABLE))\r
989 \r
990 #define IS_OB_USER_SRAM2_RST(VALUE)        (((VALUE) == OB_SRAM2_RST_ERASE) || ((VALUE) == OB_SRAM2_RST_NOT_ERASE))\r
991 \r
992 #if defined (STM32L412xx) || defined (STM32L422xx) || defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || \\r
993     defined (STM32L442xx) || defined (STM32L443xx) || defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \\r
994     defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4R5xx) || \\r
995     defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
996 #define IS_OB_USER_SWBOOT0(VALUE)          (((VALUE) == OB_BOOT0_FROM_OB) || ((VALUE) == OB_BOOT0_FROM_PIN))\r
997 \r
998 #define IS_OB_USER_BOOT0(VALUE)            (((VALUE) == OB_BOOT0_RESET) || ((VALUE) == OB_BOOT0_SET))\r
999 #endif\r
1000 \r
1001 #define IS_OB_PCROP_RDP(VALUE)             (((VALUE) == OB_PCROP_RDP_NOT_ERASE) || ((VALUE) == OB_PCROP_RDP_ERASE))\r
1002 \r
1003 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)\r
1004 #define IS_FLASH_LATENCY(LATENCY)          (((LATENCY) == FLASH_LATENCY_0) || ((LATENCY) == FLASH_LATENCY_1) || \\r
1005                                             ((LATENCY) == FLASH_LATENCY_2) || ((LATENCY) == FLASH_LATENCY_3) || \\r
1006                                             ((LATENCY) == FLASH_LATENCY_4) || ((LATENCY) == FLASH_LATENCY_5) || \\r
1007                                             ((LATENCY) == FLASH_LATENCY_6) || ((LATENCY) == FLASH_LATENCY_7) || \\r
1008                                             ((LATENCY) == FLASH_LATENCY_8) || ((LATENCY) == FLASH_LATENCY_9) || \\r
1009                                             ((LATENCY) == FLASH_LATENCY_10) || ((LATENCY) == FLASH_LATENCY_11) || \\r
1010                                             ((LATENCY) == FLASH_LATENCY_12) || ((LATENCY) == FLASH_LATENCY_13) || \\r
1011                                             ((LATENCY) == FLASH_LATENCY_14) || ((LATENCY) == FLASH_LATENCY_15))\r
1012 #else\r
1013 #define IS_FLASH_LATENCY(LATENCY)          (((LATENCY) == FLASH_LATENCY_0) || \\r
1014                                             ((LATENCY) == FLASH_LATENCY_1) || \\r
1015                                             ((LATENCY) == FLASH_LATENCY_2) || \\r
1016                                             ((LATENCY) == FLASH_LATENCY_3) || \\r
1017                                             ((LATENCY) == FLASH_LATENCY_4))\r
1018 #endif\r
1019 /**\r
1020   * @}\r
1021   */\r
1022 \r
1023 /**\r
1024   * @}\r
1025   */\r
1026 \r
1027 /**\r
1028   * @}\r
1029   */\r
1030 \r
1031 /**\r
1032   * @}\r
1033   */\r
1034 \r
1035 #ifdef __cplusplus\r
1036 }\r
1037 #endif\r
1038 \r
1039 #endif /* __STM32L4xx_HAL_FLASH_H */\r
1040 \r
1041 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r