stm32l5xx_hal_flash.h 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  1. /**
  2. ******************************************************************************
  3. * @file stm32l5xx_hal_flash.h
  4. * @author MCD Application Team
  5. * @brief Header file of FLASH HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2019 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file in
  13. * the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. ******************************************************************************
  16. */
  17. /* Define to prevent recursive inclusion -------------------------------------*/
  18. #ifndef STM32L5xx_HAL_FLASH_H
  19. #define STM32L5xx_HAL_FLASH_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* Includes ------------------------------------------------------------------*/
  24. #include "stm32l5xx_hal_def.h"
  25. /** @addtogroup STM32L5xx_HAL_Driver
  26. * @{
  27. */
  28. /** @addtogroup FLASH
  29. * @{
  30. */
  31. /* Exported types ------------------------------------------------------------*/
  32. /** @defgroup FLASH_Exported_Types FLASH Exported Types
  33. * @{
  34. */
  35. /**
  36. * @brief FLASH Erase structure definition
  37. */
  38. typedef struct
  39. {
  40. uint32_t TypeErase; /*!< Mass erase or page erase.
  41. This parameter can be a value of @ref FLASH_Type_Erase */
  42. uint32_t Banks; /*!< Select bank to erase.
  43. This parameter must be a value of @ref FLASH_Banks
  44. (FLASH_BANK_BOTH should be used only for mass erase) */
  45. uint32_t Page; /*!< Initial Flash page to erase when page erase is disabled
  46. This parameter must be a value between 0 and (max number of pages in the bank - 1)
  47. (eg : 127 for 512kB dual bank) */
  48. uint32_t NbPages; /*!< Number of pages to be erased.
  49. This parameter must be a value between 1 and (max number of pages in the bank - value of initial page)*/
  50. } FLASH_EraseInitTypeDef;
  51. /**
  52. * @brief FLASH Option Bytes Program structure definition
  53. */
  54. typedef struct
  55. {
  56. uint32_t OptionType; /*!< Option byte to be configured.
  57. This parameter can be a combination of the values of @ref FLASH_OB_Type */
  58. uint32_t WRPArea; /*!< Write protection area to be programmed (used for OPTIONBYTE_WRP).
  59. Only one WRP area could be programmed at the same time.
  60. This parameter can be value of @ref FLASH_OB_WRP_Area */
  61. uint32_t WRPStartOffset; /*!< Write protection start offset (used for OPTIONBYTE_WRP).
  62. This parameter must be a value between 0 and (max number of pages in the bank - 1)
  63. (eg : 127 for 512kB dual bank) */
  64. uint32_t WRPEndOffset; /*!< Write protection end offset (used for OPTIONBYTE_WRP).
  65. This parameter must be a value between WRPStartOffset and (max number of pages in the bank - 1) */
  66. uint32_t RDPLevel; /*!< Set the read protection level.. (used for OPTIONBYTE_RDP).
  67. This parameter can be a value of @ref FLASH_OB_Read_Protection */
  68. uint32_t USERType; /*!< User option byte(s) to be configured (used for OPTIONBYTE_USER).
  69. This parameter can be a combination of @ref FLASH_OB_USER_Type */
  70. uint32_t USERConfig; /*!< Value of the user option byte (used for OPTIONBYTE_USER).
  71. This parameter can be a combination of @ref FLASH_OB_USER_BOR_LEVEL,
  72. @ref FLASH_OB_USER_nRST_STOP, @ref FLASH_OB_USER_nRST_STANDBY,
  73. @ref FLASH_OB_USER_nRST_SHUTDOWN, @ref FLASH_OB_USER_IWDG_SW,
  74. @ref FLASH_OB_USER_IWDG_STOP, @ref FLASH_OB_USER_IWDG_STANDBY,
  75. @ref FLASH_OB_USER_WWDG_SW, @ref FLASH_OB_USER_SWAP_BANK,
  76. @ref FLASH_OB_USER_DUALBANK, @ref FLASH_OB_USER_DBANK,
  77. @ref FLASH_OB_USER_SRAM2_PAR, @ref FLASH_OB_USER_SRAM2_RST,
  78. @ref FLASH_OB_USER_nSWBOOT0, @ref FLASH_OB_USER_nBOOT0,
  79. @ref FLASH_OB_USER_PA15_PUPEN and @ref FLASH_OB_USER_TZEN */
  80. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  81. uint32_t WMSecConfig; /*!< Configuration of the Watermark-based Secure Area (used for OPTIONBYTE_WMSEC).
  82. This parameter must be a value of @ref FLASH_OB_WMSEC */
  83. uint32_t WMSecStartPage; /*!< Start page of secure area (used for OPTIONBYTE_WMSEC).
  84. This parameter must be a value between 0 and (max number of pages in the bank - 1) */
  85. uint32_t WMSecEndPage; /*!< End page of secure area (used for OPTIONBYTE_WMSEC).
  86. This parameter must be a value between WMSecStartPage and (max number of pages in the bank - 1) */
  87. uint32_t WMHDPEndPage; /*!< End page of the secure hide protection (used for OPTIONBYTE_WMSEC).
  88. This parameter must be a value between WMSecStartPage and WMPCROPStartPage
  89. (if PCROP area activated) or WMSecEndPage */
  90. uint32_t BootLock; /*!< Configuration of the boot lock (used for OPTIONBYTE_BOOT_LOCK).
  91. This parameter must be a value of @ref FLASH_OB_BOOT_LOCK */
  92. #endif
  93. uint32_t BootAddrConfig; /*!< Configuration of the Boot address (used for OPTIONBYTE_BOOTADDR).
  94. This parameter must be a value of @ref FLASH_OB_BOOTADDR */
  95. uint32_t BootAddr; /*!< Boot address (used for OPTIONBYTE_BOOTADDR).
  96. This parameter must be a value between 0x0 and 0xFFFFFF00 */
  97. } FLASH_OBProgramInitTypeDef;
  98. /**
  99. * @brief FLASH handle Structure definition
  100. */
  101. typedef struct
  102. {
  103. HAL_LockTypeDef Lock; /*!< FLASH locking object */
  104. uint32_t ErrorCode; /*!< FLASH error code */
  105. uint32_t ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */
  106. uint32_t Address; /*!< Internal variable to save address selected for program in IT context */
  107. uint32_t Bank; /*!< Internal variable to save current bank selected during erase in IT context */
  108. uint32_t Page; /*!< Internal variable to define the current page which is being erased in IT context */
  109. uint32_t NbPagesToErase; /*!< Internal variable to save the remaining pages to erase in IT context */
  110. }FLASH_ProcessTypeDef;
  111. /**
  112. * @}
  113. */
  114. /* Exported constants --------------------------------------------------------*/
  115. /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
  116. * @{
  117. */
  118. /** @defgroup FLASH_Flags FLASH Flags Definition
  119. * @{
  120. */
  121. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  122. #define FLASH_FLAG_EOP FLASH_SECSR_SECEOP /*!< FLASH End of operation flag */
  123. #define FLASH_FLAG_OPERR FLASH_SECSR_SECOPERR /*!< FLASH Operation error flag */
  124. #define FLASH_FLAG_PROGERR FLASH_SECSR_SECPROGERR /*!< FLASH Programming error flag */
  125. #define FLASH_FLAG_WRPERR FLASH_SECSR_SECWRPERR /*!< FLASH Write protection error flag */
  126. #define FLASH_FLAG_PGAERR FLASH_SECSR_SECPGAERR /*!< FLASH Programming alignment error flag */
  127. #define FLASH_FLAG_SIZERR FLASH_SECSR_SECSIZERR /*!< FLASH Size error flag */
  128. #define FLASH_FLAG_PGSERR FLASH_SECSR_SECPGSERR /*!< FLASH Programming sequence error flag */
  129. #define FLASH_FLAG_OPTWERR FLASH_NSSR_OPTWERR /*!< FLASH Option modification error flag */
  130. #define FLASH_FLAG_BSY FLASH_SECSR_SECBSY /*!< FLASH Busy flag */
  131. #define FLASH_FLAG_ECCC (FLASH_ECCR_ECCC | FLASH_ECCR_ECCC2) /*!< FLASH ECC correction */
  132. #define FLASH_FLAG_ECCD (FLASH_ECCR_ECCD | FLASH_ECCR_ECCD2) /*!< FLASH ECC detection */
  133. #define FLASH_FLAG_SR_ERRORS (FLASH_FLAG_OPERR | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \
  134. FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_PGSERR) /*!< Flash all flags from Status Register */
  135. #define FLASH_FLAG_ECCR_ERRORS (FLASH_FLAG_ECCD | FLASH_FLAG_ECCC) /*!< Flash all flags from ECC Register */
  136. #define FLASH_FLAG_ALL_ERRORS (FLASH_FLAG_SR_ERRORS | FLASH_FLAG_OPTWERR | FLASH_FLAG_ECCR_ERRORS) /*!< Flash all flags */
  137. #else
  138. #define FLASH_FLAG_EOP FLASH_NSSR_NSEOP /*!< FLASH End of operation flag */
  139. #define FLASH_FLAG_OPERR FLASH_NSSR_NSOPERR /*!< FLASH Operation error flag */
  140. #define FLASH_FLAG_PROGERR FLASH_NSSR_NSPROGERR /*!< FLASH Programming error flag */
  141. #define FLASH_FLAG_WRPERR FLASH_NSSR_NSWRPERR /*!< FLASH Write protection error flag */
  142. #define FLASH_FLAG_PGAERR FLASH_NSSR_NSPGAERR /*!< FLASH Programming alignment error flag */
  143. #define FLASH_FLAG_SIZERR FLASH_NSSR_NSSIZERR /*!< FLASH Size error flag */
  144. #define FLASH_FLAG_PGSERR FLASH_NSSR_NSPGSERR /*!< FLASH Programming sequence error flag */
  145. #define FLASH_FLAG_OPTWERR FLASH_NSSR_OPTWERR /*!< FLASH Option modification error flag */
  146. #define FLASH_FLAG_BSY FLASH_NSSR_NSBSY /*!< FLASH Busy flag */
  147. #define FLASH_FLAG_ECCC (FLASH_ECCR_ECCC | FLASH_ECCR_ECCC2) /*!< FLASH ECC correction */
  148. #define FLASH_FLAG_ECCD (FLASH_ECCR_ECCD | FLASH_ECCR_ECCD2) /*!< FLASH ECC detection */
  149. #define FLASH_FLAG_SR_ERRORS (FLASH_FLAG_OPERR | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \
  150. FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_PGSERR | \
  151. FLASH_FLAG_OPTWERR) /*!< Flash all flags from Status Register */
  152. #define FLASH_FLAG_ECCR_ERRORS (FLASH_FLAG_ECCD | FLASH_FLAG_ECCC) /*!< Flash all flags from ECC Register */
  153. #define FLASH_FLAG_ALL_ERRORS (FLASH_FLAG_SR_ERRORS | FLASH_FLAG_ECCR_ERRORS) /*!< Flash all flags */
  154. #endif
  155. /**
  156. * @}
  157. */
  158. /** @defgroup FLASH_Interrupt_definition FLASH Interrupts Definition
  159. * @brief FLASH Interrupt definition
  160. * @{
  161. */
  162. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  163. #define FLASH_IT_EOP FLASH_SECCR_SECEOPIE /*!< End of FLASH Operation Interrupt source */
  164. #define FLASH_IT_OPERR FLASH_SECCR_SECERRIE /*!< Error Interrupt source */
  165. #define FLASH_IT_ECCC (FLASH_ECCR_ECCIE >> 24) /*!< ECC Correction Interrupt source */
  166. #else
  167. #define FLASH_IT_EOP FLASH_NSCR_NSEOPIE /*!< End of FLASH Operation Interrupt source */
  168. #define FLASH_IT_OPERR FLASH_NSCR_NSERRIE /*!< Error Interrupt source */
  169. #define FLASH_IT_ECCC (FLASH_ECCR_ECCIE >> 24) /*!< ECC Correction Interrupt source */
  170. #endif
  171. /**
  172. * @}
  173. */
  174. /** @defgroup FLASH_Error FLASH Error
  175. * @{
  176. */
  177. #define HAL_FLASH_ERROR_NONE 0x00000000U /*!< Flash no error */
  178. #define HAL_FLASH_ERROR_OP FLASH_FLAG_OPERR /*!< Flash operation error */
  179. #define HAL_FLASH_ERROR_PROG FLASH_FLAG_PROGERR /*!< Flash programming error */
  180. #define HAL_FLASH_ERROR_WRP FLASH_FLAG_WRPERR /*!< Flash write protection error */
  181. #define HAL_FLASH_ERROR_PGA FLASH_FLAG_PGAERR /*!< Flash programming alignment error */
  182. #define HAL_FLASH_ERROR_SIZ FLASH_FLAG_SIZERR /*!< Flash size error */
  183. #define HAL_FLASH_ERROR_PGS FLASH_FLAG_PGSERR /*!< Flash programming sequence error */
  184. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  185. #else
  186. #define HAL_FLASH_ERROR_OPTW FLASH_FLAG_OPTWERR /*!< Flash option modification error */
  187. #endif
  188. #define HAL_FLASH_ERROR_ECCC FLASH_FLAG_ECCC /*!< Flash ECC correction error */
  189. #define HAL_FLASH_ERROR_ECCD FLASH_FLAG_ECCD /*!< Flash ECC detection error */
  190. /**
  191. * @}
  192. */
  193. /** @defgroup FLASH_Type_Erase FLASH Erase Type
  194. * @{
  195. */
  196. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  197. #define FLASH_TYPEERASE_PAGES FLASH_SECCR_SECPER /*!<Secure pages erase only*/
  198. #define FLASH_TYPEERASE_PAGES_NS (FLASH_NSCR_NSPER | FLASH_NON_SECURE_MASK) /*!<Non-secure pages erase only*/
  199. #define FLASH_TYPEERASE_MASSERASE (FLASH_SECCR_SECMER1 | FLASH_SECCR_SECMER2) /*!<Secure flash mass erase activation*/
  200. #define FLASH_TYPEERASE_MASSERASE_NS (FLASH_NSCR_NSMER1 | FLASH_NSCR_NSMER2 | FLASH_NON_SECURE_MASK) /*!<Non-secure flash mass erase activation*/
  201. #else
  202. #define FLASH_TYPEERASE_PAGES FLASH_NSCR_NSPER /*!<Pages erase only*/
  203. #define FLASH_TYPEERASE_MASSERASE (FLASH_NSCR_NSMER1 | FLASH_NSCR_NSMER2) /*!<Flash mass erase activation*/
  204. #endif
  205. /**
  206. * @}
  207. */
  208. /** @defgroup FLASH_Banks FLASH Banks
  209. * @{
  210. */
  211. #define FLASH_BANK_1 0x00000001U /*!< Bank 1 */
  212. #define FLASH_BANK_2 0x00000002U /*!< Bank 2 */
  213. #define FLASH_BANK_BOTH (FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2 */
  214. /**
  215. * @}
  216. */
  217. /** @defgroup FLASH_Type_Program FLASH Program Type
  218. * @{
  219. */
  220. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  221. #define FLASH_TYPEPROGRAM_DOUBLEWORD FLASH_SECCR_SECPG /*!<Program a double-word (64-bit) at a specified secure address.*/
  222. #define FLASH_TYPEPROGRAM_DOUBLEWORD_NS (FLASH_NSCR_NSPG | FLASH_NON_SECURE_MASK) /*!<Program a double-word (64-bit) at a specified non-secure address.*/
  223. #else
  224. #define FLASH_TYPEPROGRAM_DOUBLEWORD FLASH_NSCR_NSPG /*!<Program a double-word (64-bit) at a specified address.*/
  225. #endif
  226. /**
  227. * @}
  228. */
  229. /** @defgroup FLASH_OB_Type FLASH Option Bytes Type
  230. * @{
  231. */
  232. #define OPTIONBYTE_WRP 0x00000001U /*!< WRP option byte configuration */
  233. #define OPTIONBYTE_RDP 0x00000002U /*!< RDP option byte configuration */
  234. #define OPTIONBYTE_USER 0x00000004U /*!< USER option byte configuration */
  235. #define OPTIONBYTE_BOOTADDR 0x00000008U /*!< Boot address option byte configuration */
  236. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  237. #define OPTIONBYTE_WMSEC 0x00000010U /*!< Watermark-based secure area option byte configuration */
  238. #define OPTIONBYTE_BOOT_LOCK 0x00000020U /*!< Boot lock option byte configuration */
  239. #endif
  240. /**
  241. * @}
  242. */
  243. /** @defgroup FLASH_OB_WRP_Area FLASH WRP Area
  244. * @{
  245. */
  246. #define OB_WRPAREA_BANK1_AREAA 0x00000001U /*!< Flash Bank 1 Area A */
  247. #define OB_WRPAREA_BANK1_AREAB 0x00000002U /*!< Flash Bank 1 Area B */
  248. #define OB_WRPAREA_BANK2_AREAA 0x00000004U /*!< Flash Bank 2 Area A */
  249. #define OB_WRPAREA_BANK2_AREAB 0x00000008U /*!< Flash Bank 2 Area B */
  250. /**
  251. * @}
  252. */
  253. /** @defgroup FLASH_OB_Read_Protection FLASH Option Bytes Read Protection
  254. * @{
  255. */
  256. #define OB_RDP_LEVEL_0 ((uint32_t)0xAA) /*!< RDP level 0 code */
  257. #define OB_RDP_LEVEL_0_5 ((uint32_t)0x55) /*!< RDP level 0.5 code */
  258. #define OB_RDP_LEVEL_1 ((uint32_t)0xBB) /*!< RDP level 1 code */
  259. #define OB_RDP_LEVEL_2 ((uint32_t)0xCC) /*!< RDP level 2 code.
  260. Warning: When enabling read protection level 2
  261. it's no more possible to go back to level 1 or 0. */
  262. /**
  263. * @}
  264. */
  265. /** @defgroup FLASH_OB_USER_Type FLASH Option Bytes User Type
  266. * @{
  267. */
  268. #define OB_USER_BOR_LEV 0x00000001U /*!< BOR reset Level */
  269. #define OB_USER_nRST_STOP 0x00000002U /*!< Reset generated when entering the stop mode */
  270. #define OB_USER_nRST_STDBY 0x00000004U /*!< Reset generated when entering the standby mode */
  271. #define OB_USER_nRST_SHDW 0x00000008U /*!< Reset generated when entering the shutdown mode */
  272. #define OB_USER_IWDG_SW 0x00000010U /*!< Independent watchdog selection */
  273. #define OB_USER_IWDG_STOP 0x00000020U /*!< Independent watchdog counter freeze in stop mode */
  274. #define OB_USER_IWDG_STDBY 0x00000040U /*!< Independent watchdog counter freeze in standby mode */
  275. #define OB_USER_WWDG_SW 0x00000080U /*!< Window watchdog selection */
  276. #define OB_USER_SWAP_BANK 0x00000100U /*!< Swap banks */
  277. #define OB_USER_DUALBANK 0x00000200U /*!< Dual-Bank on 256kB Flash memory devices */
  278. #define OB_USER_DBANK 0x00000400U /*!< Single bank with 128-bits data or two banks with 64-bits data */
  279. #define OB_USER_SRAM2_PE 0x00000800U /*!< SRAM2 parity error enable */
  280. #define OB_USER_SRAM2_RST 0x00001000U /*!< SRAM2 Erase when system reset */
  281. #define OB_USER_nSWBOOT0 0x00002000U /*!< Software BOOT0 */
  282. #define OB_USER_nBOOT0 0x00004000U /*!< nBOOT0 option bit */
  283. #define OB_USER_PA15_PUPEN 0x00008000U /*!< PA15 pull-up enable option bit */
  284. #define OB_USER_TZEN 0x00010000U /*!< Global TrustZone enable */
  285. /**
  286. * @}
  287. */
  288. /** @defgroup FLASH_OB_USER_BOR_LEVEL FLASH Option Bytes User BOR Level
  289. * @{
  290. */
  291. #define OB_BOR_LEVEL_0 FLASH_OPTR_BOR_LEV_0 /*!< Reset level threshold is around 1.7V */
  292. #define OB_BOR_LEVEL_1 FLASH_OPTR_BOR_LEV_1 /*!< Reset level threshold is around 2.0V */
  293. #define OB_BOR_LEVEL_2 FLASH_OPTR_BOR_LEV_2 /*!< Reset level threshold is around 2.2V */
  294. #define OB_BOR_LEVEL_3 FLASH_OPTR_BOR_LEV_3 /*!< Reset level threshold is around 2.5V */
  295. #define OB_BOR_LEVEL_4 FLASH_OPTR_BOR_LEV_4 /*!< Reset level threshold is around 2.8V */
  296. /**
  297. * @}
  298. */
  299. /** @defgroup FLASH_OB_USER_nRST_STOP FLASH Option Bytes User Reset On Stop
  300. * @{
  301. */
  302. #define OB_STOP_RST 0x00000000U /*!< Reset generated when entering the stop mode */
  303. #define OB_STOP_NORST FLASH_OPTR_nRST_STOP /*!< No reset generated when entering the stop mode */
  304. /**
  305. * @}
  306. */
  307. /** @defgroup FLASH_OB_USER_nRST_STANDBY FLASH Option Bytes User Reset On Standby
  308. * @{
  309. */
  310. #define OB_STANDBY_RST 0x00000000U /*!< Reset generated when entering the standby mode */
  311. #define OB_STANDBY_NORST FLASH_OPTR_nRST_STDBY /*!< No reset generated when entering the standby mode */
  312. /**
  313. * @}
  314. */
  315. /** @defgroup FLASH_OB_USER_nRST_SHUTDOWN FLASH Option Bytes User Reset On Shutdown
  316. * @{
  317. */
  318. #define OB_SHUTDOWN_RST 0x00000000U /*!< Reset generated when entering the shutdown mode */
  319. #define OB_SHUTDOWN_NORST FLASH_OPTR_nRST_SHDW /*!< No reset generated when entering the shutdown mode */
  320. /**
  321. * @}
  322. */
  323. /** @defgroup FLASH_OB_USER_IWDG_SW FLASH Option Bytes User IWDG Type
  324. * @{
  325. */
  326. #define OB_IWDG_HW 0x00000000U /*!< Hardware independent watchdog */
  327. #define OB_IWDG_SW FLASH_OPTR_IWDG_SW /*!< Software independent watchdog */
  328. /**
  329. * @}
  330. */
  331. /** @defgroup FLASH_OB_USER_IWDG_STOP FLASH Option Bytes User IWDG Mode On Stop
  332. * @{
  333. */
  334. #define OB_IWDG_STOP_FREEZE 0x00000000U /*!< Independent watchdog counter is frozen in Stop mode */
  335. #define OB_IWDG_STOP_RUN FLASH_OPTR_IWDG_STOP /*!< Independent watchdog counter is running in Stop mode */
  336. /**
  337. * @}
  338. */
  339. /** @defgroup FLASH_OB_USER_IWDG_STANDBY FLASH Option Bytes User IWDG Mode On Standby
  340. * @{
  341. */
  342. #define OB_IWDG_STDBY_FREEZE 0x00000000U /*!< Independent watchdog counter is frozen in Standby mode */
  343. #define OB_IWDG_STDBY_RUN FLASH_OPTR_IWDG_STDBY /*!< Independent watchdog counter is running in Standby mode */
  344. /**
  345. * @}
  346. */
  347. /** @defgroup FLASH_OB_USER_WWDG_SW FLASH Option Bytes User WWDG Type
  348. * @{
  349. */
  350. #define OB_WWDG_HW 0x00000000U /*!< Hardware window watchdog */
  351. #define OB_WWDG_SW FLASH_OPTR_WWDG_SW /*!< Software window watchdog */
  352. /**
  353. * @}
  354. */
  355. /** @defgroup FLASH_OB_USER_SWAP_BANK FLASH Option Bytes User Swap banks
  356. * @{
  357. */
  358. #define OB_SWAP_BANK_DISABLE 0x00000000U /*!< Bank 1 is located at AHB address 0x0, Bank 2 is located at 0x40000 */
  359. #define OB_SWAP_BANK_ENABLE FLASH_OPTR_SWAP_BANK /*!< Bank 1 is located at AHB address 0x40000, Bank 2 is located at 0x0 */
  360. /**
  361. * @}
  362. */
  363. /** @defgroup FLASH_OB_USER_DUALBANK FLASH Option Bytes User Dual-bank Type
  364. * @{
  365. */
  366. #define OB_DUALBANK_SINGLE 0x00000000U /*!< 256 kB Single-bank Flash */
  367. #define OB_DUALBANK_DUAL FLASH_OPTR_DB256K /*!< 256 kB Dual-bank Flash */
  368. /**
  369. * @}
  370. */
  371. /** @defgroup FLASH_OB_USER_DBANK FLASH Option Bytes User DBANK Type
  372. * @{
  373. */
  374. #define OB_DBANK_128_BITS 0x00000000U /*!< Single-bank with 128-bits data */
  375. #define OB_DBANK_64_BITS FLASH_OPTR_DBANK /*!< Dual-bank with 64-bits data */
  376. /**
  377. * @}
  378. */
  379. /** @defgroup FLASH_OB_USER_SRAM2_PAR FLASH Option Bytes User SRAM2 Parity error enable
  380. * @{
  381. */
  382. #define OB_SRAM2_PARITY_ENABLE 0x00000000U /*!< SRAM2 parity error generation enable */
  383. #define OB_SRAM2_PARITY_DISABLE FLASH_OPTR_SRAM2_PE /*!< SRAM2 parity check disable */
  384. /**
  385. * @}
  386. */
  387. /** @defgroup FLASH_OB_USER_SRAM2_RST FLASH Option Bytes User SRAM2 Erase On Reset Type
  388. * @{
  389. */
  390. #define OB_SRAM2_RST_ERASE 0x00000000U /*!< SRAM2 erased when a system reset occurs */
  391. #define OB_SRAM2_RST_NOT_ERASE FLASH_OPTR_SRAM2_RST /*!< SRAM2 is not erased when a system reset occurs */
  392. /**
  393. * @}
  394. */
  395. /** @defgroup FLASH_OB_USER_nSWBOOT0 FLASH Option Bytes User Software BOOT0
  396. * @{
  397. */
  398. #define OB_BOOT0_FROM_OB 0x00000000U /*!< BOOT0 taken from the option bit nBOOT0 */
  399. #define OB_BOOT0_FROM_PIN FLASH_OPTR_nSWBOOT0 /*!< BOOT0 taken from BOOT0 pin */
  400. /**
  401. * @}
  402. */
  403. /** @defgroup FLASH_OB_USER_nBOOT0 FLASH Option Bytes User nBOOT0 option bit
  404. * @{
  405. */
  406. #define OB_nBOOT0_RESET 0x00000000U /*!< nBOOT0 = 0 */
  407. #define OB_nBOOT0_SET FLASH_OPTR_nBOOT0 /*!< nBOOT0 = 1 */
  408. /**
  409. * @}
  410. */
  411. /** @defgroup FLASH_OB_USER_PA15_PUPEN FLASH Option Bytes User PA15 pull-up enable option bit
  412. * @{
  413. */
  414. #define OB_PA15_PUP_DISABLE 0x00000000U /*!< USB power delivery dead-battery enabled/ TDI pull-up deactivated */
  415. #define OB_PA15_PUP_ENABLE FLASH_OPTR_PA15_PUPEN /*!< USB power delivery dead-battery disabled/ TDI pull-up activated */
  416. /**
  417. * @}
  418. */
  419. /** @defgroup FLASH_OB_USER_TZEN FLASH Option Bytes User Global TrustZone
  420. * @{
  421. */
  422. #define OB_TZEN_DISABLE 0x00000000U /*!< no TrustZone */
  423. #define OB_TZEN_ENABLE FLASH_OPTR_TZEN /*!< TrustZone */
  424. /**
  425. * @}
  426. */
  427. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  428. /** @defgroup FLASH_OB_BOOT_LOCK FLASH Option Bytes Boot Lock
  429. * @{
  430. */
  431. #define OB_BOOT_LOCK_DISABLE 0x00000000U /*!< Boot lock disable */
  432. #define OB_BOOT_LOCK_ENABLE FLASH_SECBOOTADD0R_BOOT_LOCK /*!< Boot lock enable */
  433. /**
  434. * @}
  435. */
  436. /** @defgroup FLASH_OB_WMSEC FLASH Option Bytes Watermarked-based security configuration
  437. * @{
  438. */
  439. #define OB_WMSEC_AREA1 FLASH_BANK_1 /*!< Watermarked-based security area for bank 1 */
  440. #define OB_WMSEC_AREA2 FLASH_BANK_2 /*!< Watermarked-based security area for bank 2 */
  441. #define OB_WMSEC_SECURE_AREA_CONFIG 0x00000010U /*!< Configure Watermarked-based security area */
  442. #define OB_WMSEC_HDP_AREA_CONFIG 0x00000020U /*!< Configure Watermarked-based secure hide area */
  443. #define OB_WMSEC_HDP_AREA_ENABLE 0x00000080U /*!< Enable Watermarked-based secure hide area */
  444. #define OB_WMSEC_HDP_AREA_DISABLE 0x00000100U /*!< Disable Watermarked-based secure hide area */
  445. /**
  446. * @}
  447. */
  448. #endif
  449. /** @defgroup FLASH_OB_BOOTADDR FLASH Option Bytes Boot address
  450. * @{
  451. */
  452. #define OB_BOOTADDR_NS0 0x00000001U /*!< Non-secure boot address 0 */
  453. #define OB_BOOTADDR_NS1 0x00000002U /*!< Non-secure boot address 1 */
  454. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  455. #define OB_BOOTADDR_SEC0 0x00000004U /*!< Secure boot address 0 */
  456. #endif
  457. /**
  458. * @}
  459. */
  460. /** @defgroup FLASH_Latency FLASH Latency
  461. * @{
  462. */
  463. #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero wait state */
  464. #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One wait state */
  465. #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two wait states */
  466. #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three wait states */
  467. #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four wait states */
  468. #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five wait state */
  469. #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six wait state */
  470. #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven wait states */
  471. #define FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS /*!< FLASH Eight wait states */
  472. #define FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS /*!< FLASH Nine wait states */
  473. #define FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS /*!< FLASH Ten wait state */
  474. #define FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS /*!< FLASH Eleven wait state */
  475. #define FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS /*!< FLASH Twelve wait states */
  476. #define FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS /*!< FLASH Thirteen wait states */
  477. #define FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS /*!< FLASH Fourteen wait states */
  478. #define FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS /*!< FLASH Fifteen wait states */
  479. /**
  480. * @}
  481. */
  482. /** @defgroup FLASH_Keys FLASH Keys
  483. * @{
  484. */
  485. #define FLASH_KEY1 0x45670123U /*!< Flash key1 */
  486. #define FLASH_KEY2 0xCDEF89ABU /*!< Flash key2: used with FLASH_KEY1
  487. to unlock the FLASH registers access */
  488. #define FLASH_PDKEY1 0x04152637U /*!< Flash power down key1 */
  489. #define FLASH_PDKEY2 0xFAFBFCFDU /*!< Flash power down key2: used with FLASH_PDKEY1
  490. to unlock the RUN_PD bit in FLASH_ACR */
  491. #define FLASH_OPTKEY1 0x08192A3BU /*!< Flash option byte key1 */
  492. #define FLASH_OPTKEY2 0x4C5D6E7FU /*!< Flash option byte key2: used with FLASH_OPTKEY1
  493. to allow option bytes operations */
  494. #define FLASH_LVEKEY1 0xF4F5F6F7U /*!< Flash LVE key1 */
  495. #define FLASH_LVEKEY2 0x0A1B2C3DU /*!< Flash LVE key2: used with FLASH_LVEKEY1
  496. to unblock the LVEN bit in FLASH_ACR */
  497. /**
  498. * @}
  499. */
  500. /**
  501. * @}
  502. */
  503. /* Exported macros -----------------------------------------------------------*/
  504. /** @defgroup FLASH_Exported_Macros FLASH Exported Macros
  505. * @brief macros to control FLASH features
  506. * @{
  507. */
  508. /**
  509. * @brief Set the FLASH Latency.
  510. * @param __LATENCY__ FLASH Latency.
  511. * This parameter can be one of the following values :
  512. * @arg FLASH_LATENCY_0: FLASH Zero wait state
  513. * @arg FLASH_LATENCY_1: FLASH One wait state
  514. * @arg FLASH_LATENCY_2: FLASH Two wait states
  515. * @arg FLASH_LATENCY_3: FLASH Three wait states
  516. * @arg FLASH_LATENCY_4: FLASH Four wait states
  517. * @arg FLASH_LATENCY_5: FLASH Five wait states
  518. * @arg FLASH_LATENCY_6: FLASH Six wait states
  519. * @arg FLASH_LATENCY_7: FLASH Seven wait states
  520. * @arg FLASH_LATENCY_8: FLASH Eight wait states
  521. * @arg FLASH_LATENCY_9: FLASH Nine wait states
  522. * @arg FLASH_LATENCY_10: FLASH Ten wait states
  523. * @arg FLASH_LATENCY_11: FLASH Eleven wait states
  524. * @arg FLASH_LATENCY_12: FLASH Twelve wait states
  525. * @arg FLASH_LATENCY_13: FLASH Thirteen wait states
  526. * @arg FLASH_LATENCY_14: FLASH Fourteen wait states
  527. * @arg FLASH_LATENCY_15: FLASH Fifteen wait states
  528. * @retval None
  529. */
  530. #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (__LATENCY__)))
  531. /**
  532. * @brief Get the FLASH Latency.
  533. * @retval FLASH Latency
  534. * This parameter can be one of the following values :
  535. * @arg FLASH_LATENCY_0: FLASH Zero wait state
  536. * @arg FLASH_LATENCY_1: FLASH One wait state
  537. * @arg FLASH_LATENCY_2: FLASH Two wait states
  538. * @arg FLASH_LATENCY_3: FLASH Three wait states
  539. * @arg FLASH_LATENCY_4: FLASH Four wait states
  540. * @arg FLASH_LATENCY_5: FLASH Five wait states
  541. * @arg FLASH_LATENCY_6: FLASH Six wait states
  542. * @arg FLASH_LATENCY_7: FLASH Seven wait states
  543. * @arg FLASH_LATENCY_8: FLASH Eight wait states
  544. * @arg FLASH_LATENCY_9: FLASH Nine wait states
  545. * @arg FLASH_LATENCY_10: FLASH Ten wait states
  546. * @arg FLASH_LATENCY_11: FLASH Eleven wait states
  547. * @arg FLASH_LATENCY_12: FLASH Twelve wait states
  548. * @arg FLASH_LATENCY_13: FLASH Thirteen wait states
  549. * @arg FLASH_LATENCY_14: FLASH Fourteen wait states
  550. * @arg FLASH_LATENCY_15: FLASH Fifteen wait states
  551. */
  552. #define __HAL_FLASH_GET_LATENCY() READ_BIT(FLASH->ACR, FLASH_ACR_LATENCY)
  553. /**
  554. * @brief Enable the FLASH power down during Low-power run mode.
  555. * @retval None
  556. * @note Writing this bit to 0, automatically the keys are
  557. * lost and a new unlock sequence is necessary to re-write it to 1.
  558. */
  559. #define __HAL_FLASH_POWER_DOWN_ENABLE() do { WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY1); \
  560. WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY2); \
  561. SET_BIT(FLASH->ACR, FLASH_ACR_RUN_PD); \
  562. } while (0)
  563. /**
  564. * @brief Disable the FLASH power down during Low-power run mode.
  565. * @retval None
  566. * @note Writing this bit to 1, automatically the keys are
  567. * loss and a new unlock sequence is necessary to re-write it to 0.
  568. */
  569. #define __HAL_FLASH_POWER_DOWN_DISABLE() do { WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY1); \
  570. WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY2); \
  571. CLEAR_BIT(FLASH->ACR, FLASH_ACR_RUN_PD); \
  572. } while (0)
  573. /**
  574. * @brief Enable the FLASH power down during Low-Power sleep mode
  575. * @retval None
  576. */
  577. #define __HAL_FLASH_SLEEP_POWERDOWN_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)
  578. /**
  579. * @brief Disable the FLASH power down during Low-Power sleep mode
  580. * @retval None
  581. */
  582. #define __HAL_FLASH_SLEEP_POWERDOWN_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)
  583. /**
  584. * @}
  585. */
  586. /** @defgroup FLASH_Interrupt FLASH Interrupts Macros
  587. * @brief macros to handle FLASH interrupts
  588. * @{
  589. */
  590. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  591. /**
  592. * @brief Enable secure FLASH interrupts from the secure world.
  593. * @param __INTERRUPT__ FLASH interrupt.
  594. * This parameter can be any combination of the following values:
  595. * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
  596. * @arg FLASH_IT_OPERR: Error Interrupt
  597. * @arg FLASH_IT_ECCC: ECC Correction Interrupt
  598. * @retval None
  599. */
  600. /* Enable secure FLASH interrupts from the secure world */
  601. #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { SET_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
  602. if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { SET_BIT(FLASH->SECCR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
  603. } while(0)
  604. /**
  605. * @brief Enable non-secure FLASH interrupts from the secure world.
  606. * @param __INTERRUPT__ FLASH interrupt.
  607. * This parameter can be any combination of the following values:
  608. * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
  609. * @arg FLASH_IT_OPERR: Error Interrupt
  610. * @arg FLASH_IT_ECCC: ECC Correction Interrupt
  611. * @retval None
  612. */
  613. #define __HAL_FLASH_ENABLE_IT_NS(__INTERRUPT__) do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { SET_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
  614. if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { SET_BIT(FLASH->NSCR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
  615. } while(0)
  616. #else
  617. /**
  618. * @brief Enable non-secure FLASH interrupts from the non-secure world.
  619. * @param __INTERRUPT__ FLASH interrupt.
  620. * This parameter can be any combination of the following values:
  621. * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
  622. * @arg FLASH_IT_OPERR: Error Interrupt
  623. * @arg FLASH_IT_ECCC: ECC Correction Interrupt
  624. * @retval None
  625. */
  626. #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { SET_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
  627. if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { SET_BIT(FLASH->NSCR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
  628. } while(0)
  629. #endif /* __ARM_FEATURE_CMSE */
  630. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  631. /**
  632. * @brief Disable secure FLASH interrupts from the secure world.
  633. * @param __INTERRUPT__ FLASH interrupt.
  634. * This parameter can be any combination of the following values:
  635. * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
  636. * @arg FLASH_IT_OPERR: Error Interrupt
  637. * @arg FLASH_IT_ECCC: ECC Correction Interrupt
  638. * @retval None
  639. */
  640. #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { CLEAR_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
  641. if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { CLEAR_BIT(FLASH->SECCR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
  642. } while(0)
  643. /**
  644. * @brief Disable non-secure FLASH interrupts from the secure world.
  645. * @param __INTERRUPT__ FLASH interrupt.
  646. * This parameter can be any combination of the following values:
  647. * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
  648. * @arg FLASH_IT_OPERR: Error Interrupt
  649. * @arg FLASH_IT_ECCC: ECC Correction Interrupt
  650. * @retval None
  651. */
  652. #define __HAL_FLASH_DISABLE_IT_NS(__INTERRUPT__) do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { CLEAR_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
  653. if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { CLEAR_BIT(FLASH->NSCR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
  654. } while(0)
  655. #else
  656. /**
  657. * @brief Disable non-secure FLASH interrupts from the non-secure world.
  658. * @param __INTERRUPT__ FLASH interrupt.
  659. * This parameter can be any combination of the following values:
  660. * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
  661. * @arg FLASH_IT_OPERR: Error Interrupt
  662. * @arg FLASH_IT_ECCC: ECC Correction Interrupt
  663. * @retval None
  664. */
  665. #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { CLEAR_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
  666. if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { CLEAR_BIT(FLASH->NSCR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
  667. } while(0)
  668. #endif /* __ARM_FEATURE_CMSE */
  669. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  670. /**
  671. * @brief Check whether the specified secure FLASH flags from the secure world is set or not.
  672. * @param __FLAG__ specifies the FLASH flag to check.
  673. * This parameter can be one of the following values:
  674. * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
  675. * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
  676. * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
  677. * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
  678. * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
  679. * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
  680. * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
  681. * @arg FLASH_FLAG_OPTWERR: FLASH Option modification error flag
  682. * @arg FLASH_FLAG_BSY: FLASH write/erase operations in progress flag
  683. * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
  684. * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
  685. * @retval The new state of FLASH_FLAG (SET or RESET).
  686. */
  687. #define __HAL_FLASH_GET_FLAG(__FLAG__) ((((__FLAG__) & FLASH_FLAG_ECCR_ERRORS) != 0U) ? \
  688. (READ_BIT(FLASH->ECCR, (__FLAG__)) != 0U) : \
  689. ((((__FLAG__) & (FLASH_FLAG_OPTWERR)) != 0U) ? \
  690. (READ_BIT(FLASH->NSSR, (__FLAG__)) != 0U) : \
  691. (READ_BIT(FLASH->SECSR, (__FLAG__)) != 0U)))
  692. /**
  693. * @brief Check whether the specified non-secure FLASH flags from the secure world is set or not.
  694. * @param __FLAG__ specifies the FLASH flag to check.
  695. * This parameter can be one of the following values:
  696. * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
  697. * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
  698. * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
  699. * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
  700. * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
  701. * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
  702. * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
  703. * @arg FLASH_FLAG_OPTWERR: FLASH Option modification error flag
  704. * @arg FLASH_FLAG_BSY: FLASH write/erase operations in progress flag
  705. * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
  706. * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
  707. * @retval The new state of FLASH_FLAG (SET or RESET).
  708. */
  709. #define __HAL_FLASH_GET_FLAG_NS(__FLAG__) ((((__FLAG__) & FLASH_FLAG_ECCR_ERRORS) != 0U) ? \
  710. (READ_BIT(FLASH->ECCR, (__FLAG__)) != 0U) : \
  711. (READ_BIT(FLASH->NSSR, (__FLAG__)) != 0U))
  712. #else
  713. /**
  714. * @brief Check whether the specified non-secure FLASH flags from the non-secure world is set or not.
  715. * @param __FLAG__ specifies the FLASH flag to check.
  716. * This parameter can be one of the following values:
  717. * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
  718. * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
  719. * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
  720. * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
  721. * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
  722. * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
  723. * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
  724. * @arg FLASH_FLAG_OPTWERR: FLASH Option modification error flag
  725. * @arg FLASH_FLAG_BSY: FLASH write/erase operations in progress flag
  726. * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
  727. * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
  728. * @retval The new state of FLASH_FLAG (SET or RESET).
  729. */
  730. #define __HAL_FLASH_GET_FLAG(__FLAG__) ((((__FLAG__) & FLASH_FLAG_ECCR_ERRORS) != 0U) ? \
  731. (READ_BIT(FLASH->ECCR, (__FLAG__)) != 0U) : \
  732. (READ_BIT(FLASH->NSSR, (__FLAG__)) != 0U))
  733. #endif /* __ARM_FEATURE_CMSE */
  734. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  735. /**
  736. * @brief Clear secure FLASH flags from the secure world.
  737. * @param __FLAG__ specifies the FLASH flags to clear.
  738. * This parameter can be any combination of the following values:
  739. * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
  740. * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
  741. * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
  742. * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
  743. * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
  744. * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
  745. * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
  746. * @arg FLASH_FLAG_OPTWERR: FLASH Option modification error flag (Only in non-secure)
  747. * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
  748. * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
  749. * @arg FLASH_FLAG_ALL_ERRORS: FLASH All errors flags
  750. * @retval None
  751. */
  752. #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) do { if(((__FLAG__) & FLASH_FLAG_ECCR_ERRORS) != 0U) { SET_BIT(FLASH->ECCR, ((__FLAG__) & FLASH_FLAG_ECCR_ERRORS)); }\
  753. if(((__FLAG__) & FLASH_FLAG_OPTWERR) != 0U) { SET_BIT(FLASH->NSSR, ((__FLAG__) & (FLASH_FLAG_OPTWERR))); }\
  754. if(((__FLAG__) & ~(FLASH_FLAG_ECCR_ERRORS | FLASH_FLAG_OPTWERR)) != 0U) { WRITE_REG(FLASH->SECSR, ((__FLAG__) & ~(FLASH_FLAG_ECCR_ERRORS | FLASH_FLAG_OPTWERR))); } \
  755. } while(0)
  756. /**
  757. * @brief Clear non-secure FLASH flags from the secure world.
  758. * @param __FLAG__ specifies the FLASH flags to clear.
  759. * This parameter can be any combination of the following values:
  760. * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
  761. * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
  762. * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
  763. * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
  764. * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
  765. * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
  766. * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
  767. * @arg FLASH_FLAG_OPTWERR: FLASH Option modification error flag (Only in non-secure)
  768. * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
  769. * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
  770. * @arg FLASH_FLAG_ALL_ERRORS: FLASH All errors flags
  771. * @retval None
  772. */
  773. #define __HAL_FLASH_CLEAR_FLAG_NS(__FLAG__) do { if(((__FLAG__) & FLASH_FLAG_ECCR_ERRORS) != 0U) { SET_BIT(FLASH->ECCR, ((__FLAG__) & FLASH_FLAG_ECCR_ERRORS)); }\
  774. if(((__FLAG__) & ~(FLASH_FLAG_ECCR_ERRORS)) != 0U) { WRITE_REG(FLASH->NSSR, ((__FLAG__) & ~(FLASH_FLAG_ECCR_ERRORS))); }\
  775. } while(0)
  776. #else
  777. /**
  778. * @brief Clear non-secure FLASH flags from the non-secure world.
  779. * @param __FLAG__ specifies the FLASH flags to clear.
  780. * This parameter can be any combination of the following values:
  781. * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
  782. * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
  783. * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
  784. * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
  785. * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
  786. * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
  787. * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
  788. * @arg FLASH_FLAG_OPTWERR: FLASH Option modification error flag (Only in non-secure)
  789. * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
  790. * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
  791. * @arg FLASH_FLAG_ALL_ERRORS: FLASH All errors flags
  792. * @retval None
  793. */
  794. #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) do { if(((__FLAG__) & FLASH_FLAG_ECCR_ERRORS) != 0U) { SET_BIT(FLASH->ECCR, ((__FLAG__) & FLASH_FLAG_ECCR_ERRORS)); }\
  795. if(((__FLAG__) & ~(FLASH_FLAG_ECCR_ERRORS)) != 0U) { WRITE_REG(FLASH->NSSR, ((__FLAG__) & ~(FLASH_FLAG_ECCR_ERRORS))); }\
  796. } while(0)
  797. #endif /* __ARM_FEATURE_CMSE */
  798. /**
  799. * @}
  800. */
  801. /* Include FLASH HAL Extended module */
  802. #include "stm32l5xx_hal_flash_ex.h"
  803. #include "stm32l5xx_hal_flash_ramfunc.h"
  804. /* Exported functions --------------------------------------------------------*/
  805. /** @addtogroup FLASH_Exported_Functions
  806. * @{
  807. */
  808. /* Program operation functions ***********************************************/
  809. /** @addtogroup FLASH_Exported_Functions_Group1
  810. * @{
  811. */
  812. HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
  813. HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
  814. /* FLASH IRQ handler method */
  815. void HAL_FLASH_IRQHandler(void);
  816. /* Callbacks in non blocking modes */
  817. void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
  818. void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
  819. /**
  820. * @}
  821. */
  822. /* Peripheral Control functions **********************************************/
  823. /** @addtogroup FLASH_Exported_Functions_Group2
  824. * @{
  825. */
  826. HAL_StatusTypeDef HAL_FLASH_Unlock(void);
  827. HAL_StatusTypeDef HAL_FLASH_Lock(void);
  828. /* Option bytes control */
  829. HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
  830. HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
  831. HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
  832. /**
  833. * @}
  834. */
  835. /* Peripheral State functions ************************************************/
  836. /** @addtogroup FLASH_Exported_Functions_Group3
  837. * @{
  838. */
  839. uint32_t HAL_FLASH_GetError(void);
  840. /**
  841. * @}
  842. */
  843. /**
  844. * @}
  845. */
  846. /* Private variables ---------------------------------------------------------*/
  847. /** @addtogroup FLASH_Private_Variables FLASH Private Variables
  848. * @{
  849. */
  850. extern FLASH_ProcessTypeDef pFlash;
  851. /**
  852. * @}
  853. */
  854. /* Private function ----------------------------------------------------------*/
  855. /** @addtogroup FLASH_Private_Functions FLASH Private Functions
  856. * @{
  857. */
  858. HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);
  859. /**
  860. * @}
  861. */
  862. /* Private constants ---------------------------------------------------------*/
  863. /** @defgroup FLASH_Private_Constants FLASH Private Constants
  864. * @{
  865. */
  866. #define FLASH_BANK_SIZE (FLASH_SIZE >> 1)
  867. #define FLASH_PAGE_SIZE 0x00000800U
  868. #define FLASH_PAGE_SIZE_128_BITS 0x00001000U
  869. #define FLASH_PAGE_NB (FLASH_SIZE / FLASH_PAGE_SIZE)
  870. #define FLASH_PAGE_NB_PER_BANK (FLASH_BANK_SIZE / FLASH_PAGE_SIZE)
  871. #define FLASH_PAGE_NB_128_BITS (FLASH_SIZE / FLASH_PAGE_SIZE_128_BITS)
  872. #define FLASH_TIMEOUT_VALUE 1000u /* 1 s */
  873. #define FLASH_NON_SECURE_MASK 0x80000000U
  874. /**
  875. * @}
  876. */
  877. /* Private macros ------------------------------------------------------------*/
  878. /** @defgroup FLASH_Private_Macros FLASH Private Macros
  879. * @{
  880. */
  881. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  882. #define IS_FLASH_TYPEERASE(VALUE) (((VALUE) == FLASH_TYPEERASE_PAGES) || \
  883. ((VALUE) == FLASH_TYPEERASE_PAGES_NS) || \
  884. ((VALUE) == FLASH_TYPEERASE_MASSERASE) || \
  885. ((VALUE) == FLASH_TYPEERASE_MASSERASE_NS))
  886. #else
  887. #define IS_FLASH_TYPEERASE(VALUE) (((VALUE) == FLASH_TYPEERASE_PAGES) || \
  888. ((VALUE) == FLASH_TYPEERASE_MASSERASE))
  889. #endif
  890. #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
  891. ((BANK) == FLASH_BANK_2) || \
  892. ((BANK) == FLASH_BANK_BOTH))
  893. #define IS_FLASH_BANK_EXCLUSIVE(BANK) (((BANK) == FLASH_BANK_1) || \
  894. ((BANK) == FLASH_BANK_2))
  895. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  896. #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD) || \
  897. ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD_NS))
  898. #else
  899. #define IS_FLASH_TYPEPROGRAM(VALUE) ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD)
  900. #endif
  901. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  902. #define IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS) ((((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE+FLASH_SIZE))) || \
  903. (((ADDRESS) >= FLASH_BASE_NS) && ((ADDRESS) < (FLASH_BASE_NS+FLASH_SIZE))))
  904. #else
  905. #define IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE+FLASH_SIZE)))
  906. #endif
  907. #define IS_FLASH_OTP_ADDRESS(ADDRESS) (((ADDRESS) >= OTP_BASE) && ((ADDRESS) < (OTP_BASE+OTP_SIZE)))
  908. #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) ((IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS)) || (IS_FLASH_OTP_ADDRESS(ADDRESS)))
  909. #define IS_FLASH_PAGE(PAGE) ((PAGE) < 128U)
  910. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  911. #define IS_OPTIONBYTE(VALUE) (((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | \
  912. OPTIONBYTE_WMSEC | OPTIONBYTE_BOOT_LOCK | OPTIONBYTE_BOOTADDR)))
  913. #else
  914. #define IS_OPTIONBYTE(VALUE) (((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | \
  915. OPTIONBYTE_BOOTADDR)))
  916. #endif
  917. #define IS_OB_WRPAREA(VALUE) (((VALUE) == OB_WRPAREA_BANK1_AREAA) || ((VALUE) == OB_WRPAREA_BANK1_AREAB) || \
  918. ((VALUE) == OB_WRPAREA_BANK2_AREAA) || ((VALUE) == OB_WRPAREA_BANK2_AREAB))
  919. #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
  920. ((LEVEL) == OB_RDP_LEVEL_0_5) ||\
  921. ((LEVEL) == OB_RDP_LEVEL_1) ||\
  922. ((LEVEL) == OB_RDP_LEVEL_2))
  923. #define IS_OB_USER_TYPE(TYPE) (((TYPE) <= (uint32_t)0x1FFFFU) && ((TYPE) != 0U))
  924. #define IS_OB_USER_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL_0) || ((LEVEL) == OB_BOR_LEVEL_1) || \
  925. ((LEVEL) == OB_BOR_LEVEL_2) || ((LEVEL) == OB_BOR_LEVEL_3) || \
  926. ((LEVEL) == OB_BOR_LEVEL_4))
  927. #define IS_OB_USER_STOP(VALUE) (((VALUE) == OB_STOP_RST) || ((VALUE) == OB_STOP_NORST))
  928. #define IS_OB_USER_STANDBY(VALUE) (((VALUE) == OB_STANDBY_RST) || ((VALUE) == OB_STANDBY_NORST))
  929. #define IS_OB_USER_SHUTDOWN(VALUE) (((VALUE) == OB_SHUTDOWN_RST) || ((VALUE) == OB_SHUTDOWN_NORST))
  930. #define IS_OB_USER_IWDG(VALUE) (((VALUE) == OB_IWDG_HW) || ((VALUE) == OB_IWDG_SW))
  931. #define IS_OB_USER_IWDG_STOP(VALUE) (((VALUE) == OB_IWDG_STOP_FREEZE) || ((VALUE) == OB_IWDG_STOP_RUN))
  932. #define IS_OB_USER_IWDG_STDBY(VALUE) (((VALUE) == OB_IWDG_STDBY_FREEZE) || ((VALUE) == OB_IWDG_STDBY_RUN))
  933. #define IS_OB_USER_WWDG(VALUE) (((VALUE) == OB_WWDG_HW) || ((VALUE) == OB_WWDG_SW))
  934. #define IS_OB_USER_SWAP_BANK(VALUE) (((VALUE) == OB_SWAP_BANK_DISABLE) || ((VALUE) == OB_SWAP_BANK_ENABLE))
  935. #define IS_OB_USER_DUALBANK(VALUE) (((VALUE) == OB_DUALBANK_SINGLE) || ((VALUE) == OB_DUALBANK_DUAL))
  936. #define IS_OB_USER_DBANK(VALUE) (((VALUE) == OB_DBANK_128_BITS) || ((VALUE) == OB_DBANK_64_BITS))
  937. #define IS_OB_USER_SRAM2_PARITY(VALUE) (((VALUE) == OB_SRAM2_PARITY_ENABLE) || ((VALUE) == OB_SRAM2_PARITY_DISABLE))
  938. #define IS_OB_USER_SRAM2_RST(VALUE) (((VALUE) == OB_SRAM2_RST_ERASE) || ((VALUE) == OB_SRAM2_RST_NOT_ERASE))
  939. #define IS_OB_USER_SWBOOT0(VALUE) (((VALUE) == OB_BOOT0_FROM_OB) || ((VALUE) == OB_BOOT0_FROM_PIN))
  940. #define IS_OB_USER_BOOT0(VALUE) (((VALUE) == OB_nBOOT0_RESET) || ((VALUE) == OB_nBOOT0_SET))
  941. #define IS_OB_USER_PA15_PUPEN(VALUE) (((VALUE) == OB_PA15_PUP_DISABLE) || ((VALUE) == OB_PA15_PUP_ENABLE))
  942. #define IS_OB_USER_TZEN(VALUE) (((VALUE) == OB_TZEN_DISABLE) || ((VALUE) == OB_TZEN_ENABLE))
  943. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  944. #define IS_OB_BOOT_LOCK(VALUE) (((VALUE) == OB_BOOT_LOCK_DISABLE) || ((VALUE) == OB_BOOT_LOCK_ENABLE))
  945. #define IS_OB_WMSEC_CONFIG(CFG) ((((CFG) & 0x1B3U) != 0U) && (((CFG) & 0x3U) != 0U) && (((CFG) & 0xFFFFFE4CU) == 0U))
  946. #define IS_OB_WMSEC_AREA_EXCLUSIVE(WMSEC) (((((WMSEC) & OB_WMSEC_AREA1) != 0U) && (((WMSEC) & OB_WMSEC_AREA2) == 0U)) || \
  947. ((((WMSEC) & OB_WMSEC_AREA2) != 0U) && (((WMSEC) & OB_WMSEC_AREA1) == 0U)))
  948. #endif
  949. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  950. #define IS_OB_BOOTADDR_CONFIG(CFG) (((CFG) == OB_BOOTADDR_NS0) || ((CFG) == OB_BOOTADDR_NS1) || \
  951. ((CFG) == OB_BOOTADDR_SEC0))
  952. #else
  953. #define IS_OB_BOOTADDR_CONFIG(CFG) (((CFG) == OB_BOOTADDR_NS0) || ((CFG) == OB_BOOTADDR_NS1))
  954. #endif
  955. #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || ((LATENCY) == FLASH_LATENCY_1) || \
  956. ((LATENCY) == FLASH_LATENCY_2) || ((LATENCY) == FLASH_LATENCY_3) || \
  957. ((LATENCY) == FLASH_LATENCY_4) || ((LATENCY) == FLASH_LATENCY_5) || \
  958. ((LATENCY) == FLASH_LATENCY_6) || ((LATENCY) == FLASH_LATENCY_7) || \
  959. ((LATENCY) == FLASH_LATENCY_8) || ((LATENCY) == FLASH_LATENCY_9) || \
  960. ((LATENCY) == FLASH_LATENCY_10) || ((LATENCY) == FLASH_LATENCY_11) || \
  961. ((LATENCY) == FLASH_LATENCY_12) || ((LATENCY) == FLASH_LATENCY_13) || \
  962. ((LATENCY) == FLASH_LATENCY_14) || ((LATENCY) == FLASH_LATENCY_15))
  963. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  964. #define IS_FLASH_SECURE_OPERATION() ((pFlash.ProcedureOnGoing & FLASH_NON_SECURE_MASK) == 0U)
  965. #else
  966. #define IS_FLASH_SECURE_OPERATION() (0U)
  967. #endif /* __ARM_FEATURE_CMSE */
  968. /**
  969. * @}
  970. */
  971. /**
  972. * @}
  973. */
  974. /**
  975. * @}
  976. */
  977. #ifdef __cplusplus
  978. }
  979. #endif
  980. #endif /* STM32L5xx_HAL_FLASH_H */