stm32f4xx_hal_flash_ex.h 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_flash_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of FLASH HAL Extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F4xx_HAL_FLASH_EX_H
  37. #define __STM32F4xx_HAL_FLASH_EX_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f4xx_hal_def.h"
  43. /** @addtogroup STM32F4xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup FLASHEx
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /** @defgroup FLASHEx_Exported_Types FLASH Exported Types
  51. * @{
  52. */
  53. /**
  54. * @brief FLASH Erase structure definition
  55. */
  56. typedef struct
  57. {
  58. uint32_t TypeErase; /*!< Mass erase or sector Erase.
  59. This parameter can be a value of @ref FLASHEx_Type_Erase */
  60. uint32_t Banks; /*!< Select banks to erase when Mass erase is enabled.
  61. This parameter must be a value of @ref FLASHEx_Banks */
  62. uint32_t Sector; /*!< Initial FLASH sector to erase when Mass erase is disabled
  63. This parameter must be a value of @ref FLASHEx_Sectors */
  64. uint32_t NbSectors; /*!< Number of sectors to be erased.
  65. This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/
  66. uint32_t VoltageRange;/*!< The device voltage range which defines the erase parallelism
  67. This parameter must be a value of @ref FLASHEx_Voltage_Range */
  68. } FLASH_EraseInitTypeDef;
  69. /**
  70. * @brief FLASH Option Bytes Program structure definition
  71. */
  72. typedef struct
  73. {
  74. uint32_t OptionType; /*!< Option byte to be configured.
  75. This parameter can be a value of @ref FLASHEx_Option_Type */
  76. uint32_t WRPState; /*!< Write protection activation or deactivation.
  77. This parameter can be a value of @ref FLASHEx_WRP_State */
  78. uint32_t WRPSector; /*!< Specifies the sector(s) to be write protected.
  79. The value of this parameter depend on device used within the same series */
  80. uint32_t Banks; /*!< Select banks for WRP activation/deactivation of all sectors.
  81. This parameter must be a value of @ref FLASHEx_Banks */
  82. uint32_t RDPLevel; /*!< Set the read protection level.
  83. This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */
  84. uint32_t BORLevel; /*!< Set the BOR Level.
  85. This parameter can be a value of @ref FLASHEx_BOR_Reset_Level */
  86. uint8_t USERConfig; /*!< Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. */
  87. } FLASH_OBProgramInitTypeDef;
  88. /**
  89. * @brief FLASH Advanced Option Bytes Program structure definition
  90. */
  91. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  92. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  93. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  94. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  95. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  96. typedef struct
  97. {
  98. uint32_t OptionType; /*!< Option byte to be configured for extension.
  99. This parameter can be a value of @ref FLASHEx_Advanced_Option_Type */
  100. uint32_t PCROPState; /*!< PCROP activation or deactivation.
  101. This parameter can be a value of @ref FLASHEx_PCROP_State */
  102. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  103. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  104. uint16_t Sectors; /*!< specifies the sector(s) set for PCROP.
  105. This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */
  106. #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx ||\
  107. STM32F412Cx || STM32F413xx || STM32F423xx */
  108. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  109. uint32_t Banks; /*!< Select banks for PCROP activation/deactivation of all sectors.
  110. This parameter must be a value of @ref FLASHEx_Banks */
  111. uint16_t SectorsBank1; /*!< Specifies the sector(s) set for PCROP for Bank1.
  112. This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */
  113. uint16_t SectorsBank2; /*!< Specifies the sector(s) set for PCROP for Bank2.
  114. This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */
  115. uint8_t BootConfig; /*!< Specifies Option bytes for boot config.
  116. This parameter can be a value of @ref FLASHEx_Dual_Boot */
  117. #endif /*STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  118. }FLASH_AdvOBProgramInitTypeDef;
  119. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx ||
  120. STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  121. /**
  122. * @}
  123. */
  124. /* Exported constants --------------------------------------------------------*/
  125. /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants
  126. * @{
  127. */
  128. /** @defgroup FLASHEx_Type_Erase FLASH Type Erase
  129. * @{
  130. */
  131. #define FLASH_TYPEERASE_SECTORS 0x00000000U /*!< Sectors erase only */
  132. #define FLASH_TYPEERASE_MASSERASE 0x00000001U /*!< Flash Mass erase activation */
  133. /**
  134. * @}
  135. */
  136. /** @defgroup FLASHEx_Voltage_Range FLASH Voltage Range
  137. * @{
  138. */
  139. #define FLASH_VOLTAGE_RANGE_1 0x00000000U /*!< Device operating range: 1.8V to 2.1V */
  140. #define FLASH_VOLTAGE_RANGE_2 0x00000001U /*!< Device operating range: 2.1V to 2.7V */
  141. #define FLASH_VOLTAGE_RANGE_3 0x00000002U /*!< Device operating range: 2.7V to 3.6V */
  142. #define FLASH_VOLTAGE_RANGE_4 0x00000003U /*!< Device operating range: 2.7V to 3.6V + External Vpp */
  143. /**
  144. * @}
  145. */
  146. /** @defgroup FLASHEx_WRP_State FLASH WRP State
  147. * @{
  148. */
  149. #define OB_WRPSTATE_DISABLE 0x00000000U /*!< Disable the write protection of the desired bank 1 sectors */
  150. #define OB_WRPSTATE_ENABLE 0x00000001U /*!< Enable the write protection of the desired bank 1 sectors */
  151. /**
  152. * @}
  153. */
  154. /** @defgroup FLASHEx_Option_Type FLASH Option Type
  155. * @{
  156. */
  157. #define OPTIONBYTE_WRP 0x00000001U /*!< WRP option byte configuration */
  158. #define OPTIONBYTE_RDP 0x00000002U /*!< RDP option byte configuration */
  159. #define OPTIONBYTE_USER 0x00000004U /*!< USER option byte configuration */
  160. #define OPTIONBYTE_BOR 0x00000008U /*!< BOR option byte configuration */
  161. /**
  162. * @}
  163. */
  164. /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASH Option Bytes Read Protection
  165. * @{
  166. */
  167. #define OB_RDP_LEVEL_0 ((uint8_t)0xAA)
  168. #define OB_RDP_LEVEL_1 ((uint8_t)0x55)
  169. #define OB_RDP_LEVEL_2 ((uint8_t)0xCC) /*!< Warning: When enabling read protection level 2
  170. it s no more possible to go back to level 1 or 0 */
  171. /**
  172. * @}
  173. */
  174. /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASH Option Bytes IWatchdog
  175. * @{
  176. */
  177. #define OB_IWDG_SW ((uint8_t)0x20) /*!< Software IWDG selected */
  178. #define OB_IWDG_HW ((uint8_t)0x00) /*!< Hardware IWDG selected */
  179. /**
  180. * @}
  181. */
  182. /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASH Option Bytes nRST_STOP
  183. * @{
  184. */
  185. #define OB_STOP_NO_RST ((uint8_t)0x40) /*!< No reset generated when entering in STOP */
  186. #define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */
  187. /**
  188. * @}
  189. */
  190. /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASH Option Bytes nRST_STDBY
  191. * @{
  192. */
  193. #define OB_STDBY_NO_RST ((uint8_t)0x80) /*!< No reset generated when entering in STANDBY */
  194. #define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */
  195. /**
  196. * @}
  197. */
  198. /** @defgroup FLASHEx_BOR_Reset_Level FLASH BOR Reset Level
  199. * @{
  200. */
  201. #define OB_BOR_LEVEL3 ((uint8_t)0x00) /*!< Supply voltage ranges from 2.70 to 3.60 V */
  202. #define OB_BOR_LEVEL2 ((uint8_t)0x04) /*!< Supply voltage ranges from 2.40 to 2.70 V */
  203. #define OB_BOR_LEVEL1 ((uint8_t)0x08) /*!< Supply voltage ranges from 2.10 to 2.40 V */
  204. #define OB_BOR_OFF ((uint8_t)0x0C) /*!< Supply voltage ranges from 1.62 to 2.10 V */
  205. /**
  206. * @}
  207. */
  208. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  209. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  210. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  211. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  212. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  213. /** @defgroup FLASHEx_PCROP_State FLASH PCROP State
  214. * @{
  215. */
  216. #define OB_PCROP_STATE_DISABLE 0x00000000U /*!< Disable PCROP */
  217. #define OB_PCROP_STATE_ENABLE 0x00000001U /*!< Enable PCROP */
  218. /**
  219. * @}
  220. */
  221. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  222. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  223. STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  224. /** @defgroup FLASHEx_Advanced_Option_Type FLASH Advanced Option Type
  225. * @{
  226. */
  227. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  228. defined(STM32F469xx) || defined(STM32F479xx)
  229. #define OPTIONBYTE_PCROP 0x00000001U /*!< PCROP option byte configuration */
  230. #define OPTIONBYTE_BOOTCONFIG 0x00000002U /*!< BOOTConfig option byte configuration */
  231. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  232. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  233. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  234. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
  235. defined(STM32F423xx)
  236. #define OPTIONBYTE_PCROP 0x00000001U /*!<PCROP option byte configuration */
  237. #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx ||
  238. STM32F413xx || STM32F423xx */
  239. /**
  240. * @}
  241. */
  242. /** @defgroup FLASH_Latency FLASH Latency
  243. * @{
  244. */
  245. /*------------------------- STM32F42xxx/STM32F43xxx/STM32F446xx/STM32F469xx/STM32F479xx ----------------------*/
  246. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  247. defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  248. #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */
  249. #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */
  250. #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */
  251. #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */
  252. #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */
  253. #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */
  254. #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */
  255. #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */
  256. #define FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS /*!< FLASH Eight Latency cycles */
  257. #define FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS /*!< FLASH Nine Latency cycles */
  258. #define FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS /*!< FLASH Ten Latency cycles */
  259. #define FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS /*!< FLASH Eleven Latency cycles */
  260. #define FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS /*!< FLASH Twelve Latency cycles */
  261. #define FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS /*!< FLASH Thirteen Latency cycles */
  262. #define FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS /*!< FLASH Fourteen Latency cycles */
  263. #define FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS /*!< FLASH Fifteen Latency cycles */
  264. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  265. /*--------------------------------------------------------------------------------------------------------------*/
  266. /*-------------------------- STM32F40xxx/STM32F41xxx/STM32F401xx/STM32F411xx/STM32F423xx -----------------------*/
  267. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  268. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  269. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
  270. defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  271. #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */
  272. #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */
  273. #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */
  274. #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */
  275. #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */
  276. #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */
  277. #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */
  278. #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */
  279. #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx ||
  280. STM32F413xx || STM32F423xx */
  281. /*--------------------------------------------------------------------------------------------------------------*/
  282. /**
  283. * @}
  284. */
  285. /** @defgroup FLASHEx_Banks FLASH Banks
  286. * @{
  287. */
  288. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  289. defined(STM32F469xx) || defined(STM32F479xx)
  290. #define FLASH_BANK_1 1U /*!< Bank 1 */
  291. #define FLASH_BANK_2 2U /*!< Bank 2 */
  292. #define FLASH_BANK_BOTH ((uint32_t)FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2 */
  293. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  294. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  295. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  296. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  297. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
  298. defined(STM32F423xx)
  299. #define FLASH_BANK_1 1U /*!< Bank 1 */
  300. #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx
  301. STM32F413xx || STM32F423xx */
  302. /**
  303. * @}
  304. */
  305. /** @defgroup FLASHEx_MassErase_bit FLASH Mass Erase bit
  306. * @{
  307. */
  308. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  309. defined(STM32F469xx) || defined(STM32F479xx)
  310. #define FLASH_MER_BIT (FLASH_CR_MER1 | FLASH_CR_MER2) /*!< 2 MER bits here to clear */
  311. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  312. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  313. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  314. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  315. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
  316. defined(STM32F423xx)
  317. #define FLASH_MER_BIT (FLASH_CR_MER) /*!< only 1 MER Bit */
  318. #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx
  319. STM32F413xx || STM32F423xx */
  320. /**
  321. * @}
  322. */
  323. /** @defgroup FLASHEx_Sectors FLASH Sectors
  324. * @{
  325. */
  326. /*-------------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx ------------------------------------*/
  327. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  328. defined(STM32F469xx) || defined(STM32F479xx)
  329. #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
  330. #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
  331. #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
  332. #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
  333. #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
  334. #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
  335. #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
  336. #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
  337. #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */
  338. #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */
  339. #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */
  340. #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */
  341. #define FLASH_SECTOR_12 12U /*!< Sector Number 12 */
  342. #define FLASH_SECTOR_13 13U /*!< Sector Number 13 */
  343. #define FLASH_SECTOR_14 14U /*!< Sector Number 14 */
  344. #define FLASH_SECTOR_15 15U /*!< Sector Number 15 */
  345. #define FLASH_SECTOR_16 16U /*!< Sector Number 16 */
  346. #define FLASH_SECTOR_17 17U /*!< Sector Number 17 */
  347. #define FLASH_SECTOR_18 18U /*!< Sector Number 18 */
  348. #define FLASH_SECTOR_19 19U /*!< Sector Number 19 */
  349. #define FLASH_SECTOR_20 20U /*!< Sector Number 20 */
  350. #define FLASH_SECTOR_21 21U /*!< Sector Number 21 */
  351. #define FLASH_SECTOR_22 22U /*!< Sector Number 22 */
  352. #define FLASH_SECTOR_23 23U /*!< Sector Number 23 */
  353. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  354. /*-----------------------------------------------------------------------------------------------------*/
  355. /*-------------------------------------- STM32F413xx/STM32F423xx --------------------------------------*/
  356. #if defined(STM32F413xx) || defined(STM32F423xx)
  357. #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
  358. #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
  359. #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
  360. #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
  361. #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
  362. #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
  363. #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
  364. #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
  365. #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */
  366. #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */
  367. #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */
  368. #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */
  369. #define FLASH_SECTOR_12 12U /*!< Sector Number 12 */
  370. #define FLASH_SECTOR_13 13U /*!< Sector Number 13 */
  371. #define FLASH_SECTOR_14 14U /*!< Sector Number 14 */
  372. #define FLASH_SECTOR_15 15U /*!< Sector Number 15 */
  373. #endif /* STM32F413xx || STM32F423xx */
  374. /*-----------------------------------------------------------------------------------------------------*/
  375. /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
  376. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  377. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  378. #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
  379. #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
  380. #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
  381. #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
  382. #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
  383. #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
  384. #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
  385. #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
  386. #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */
  387. #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */
  388. #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */
  389. #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */
  390. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  391. /*-----------------------------------------------------------------------------------------------------*/
  392. /*--------------------------------------------- STM32F401xC -------------------------------------------*/
  393. #if defined(STM32F401xC)
  394. #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
  395. #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
  396. #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
  397. #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
  398. #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
  399. #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
  400. #endif /* STM32F401xC */
  401. /*-----------------------------------------------------------------------------------------------------*/
  402. /*--------------------------------------------- STM32F410xx -------------------------------------------*/
  403. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  404. #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
  405. #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
  406. #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
  407. #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
  408. #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
  409. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  410. /*-----------------------------------------------------------------------------------------------------*/
  411. /*---------------------------------- STM32F401xE/STM32F411xE/STM32F446xx ------------------------------*/
  412. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  413. #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
  414. #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
  415. #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
  416. #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
  417. #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
  418. #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
  419. #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
  420. #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
  421. #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
  422. /*-----------------------------------------------------------------------------------------------------*/
  423. /**
  424. * @}
  425. */
  426. /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
  427. * @{
  428. */
  429. /*--------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx -------------------------*/
  430. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  431. defined(STM32F469xx) || defined(STM32F479xx)
  432. #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
  433. #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
  434. #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
  435. #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
  436. #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
  437. #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
  438. #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */
  439. #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */
  440. #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */
  441. #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */
  442. #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */
  443. #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */
  444. #define OB_WRP_SECTOR_12 0x00000001U << 12U /*!< Write protection of Sector12 */
  445. #define OB_WRP_SECTOR_13 0x00000002U << 12U /*!< Write protection of Sector13 */
  446. #define OB_WRP_SECTOR_14 0x00000004U << 12U /*!< Write protection of Sector14 */
  447. #define OB_WRP_SECTOR_15 0x00000008U << 12U /*!< Write protection of Sector15 */
  448. #define OB_WRP_SECTOR_16 0x00000010U << 12U /*!< Write protection of Sector16 */
  449. #define OB_WRP_SECTOR_17 0x00000020U << 12U /*!< Write protection of Sector17 */
  450. #define OB_WRP_SECTOR_18 0x00000040U << 12U /*!< Write protection of Sector18 */
  451. #define OB_WRP_SECTOR_19 0x00000080U << 12U /*!< Write protection of Sector19 */
  452. #define OB_WRP_SECTOR_20 0x00000100U << 12U /*!< Write protection of Sector20 */
  453. #define OB_WRP_SECTOR_21 0x00000200U << 12U /*!< Write protection of Sector21 */
  454. #define OB_WRP_SECTOR_22 0x00000400U << 12U /*!< Write protection of Sector22 */
  455. #define OB_WRP_SECTOR_23 0x00000800U << 12U /*!< Write protection of Sector23 */
  456. #define OB_WRP_SECTOR_All 0x00000FFFU << 12U /*!< Write protection of all Sectors */
  457. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  458. /*-----------------------------------------------------------------------------------------------------*/
  459. /*--------------------------------------- STM32F413xx/STM32F423xx -------------------------------------*/
  460. #if defined(STM32F413xx) || defined(STM32F423xx)
  461. #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
  462. #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
  463. #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
  464. #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
  465. #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
  466. #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
  467. #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */
  468. #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */
  469. #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */
  470. #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */
  471. #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */
  472. #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */
  473. #define OB_WRP_SECTOR_12 0x00001000U /*!< Write protection of Sector12 */
  474. #define OB_WRP_SECTOR_13 0x00002000U /*!< Write protection of Sector13 */
  475. #define OB_WRP_SECTOR_14 0x00004000U /*!< Write protection of Sector14 */
  476. #define OB_WRP_SECTOR_15 0x00004000U /*!< Write protection of Sector15 */
  477. #define OB_WRP_SECTOR_All 0x00007FFFU /*!< Write protection of all Sectors */
  478. #endif /* STM32F413xx || STM32F423xx */
  479. /*-----------------------------------------------------------------------------------------------------*/
  480. /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
  481. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  482. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  483. #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
  484. #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
  485. #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
  486. #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
  487. #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
  488. #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
  489. #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */
  490. #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */
  491. #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */
  492. #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */
  493. #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */
  494. #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */
  495. #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */
  496. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  497. /*-----------------------------------------------------------------------------------------------------*/
  498. /*--------------------------------------------- STM32F401xC -------------------------------------------*/
  499. #if defined(STM32F401xC)
  500. #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
  501. #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
  502. #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
  503. #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
  504. #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
  505. #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
  506. #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */
  507. #endif /* STM32F401xC */
  508. /*-----------------------------------------------------------------------------------------------------*/
  509. /*--------------------------------------------- STM32F410xx -------------------------------------------*/
  510. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  511. #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
  512. #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
  513. #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
  514. #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
  515. #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
  516. #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */
  517. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  518. /*-----------------------------------------------------------------------------------------------------*/
  519. /*---------------------------------- STM32F401xE/STM32F411xE/STM32F446xx ------------------------------*/
  520. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  521. #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
  522. #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
  523. #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
  524. #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
  525. #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
  526. #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
  527. #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */
  528. #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */
  529. #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */
  530. #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
  531. /*-----------------------------------------------------------------------------------------------------*/
  532. /**
  533. * @}
  534. */
  535. /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASH Option Bytes PC ReadWrite Protection
  536. * @{
  537. */
  538. /*-------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx ---------------------------*/
  539. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  540. defined(STM32F469xx) || defined(STM32F479xx)
  541. #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
  542. #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
  543. #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
  544. #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
  545. #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
  546. #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */
  547. #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */
  548. #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */
  549. #define OB_PCROP_SECTOR_8 0x00000100U /*!< PC Read/Write protection of Sector8 */
  550. #define OB_PCROP_SECTOR_9 0x00000200U /*!< PC Read/Write protection of Sector9 */
  551. #define OB_PCROP_SECTOR_10 0x00000400U /*!< PC Read/Write protection of Sector10 */
  552. #define OB_PCROP_SECTOR_11 0x00000800U /*!< PC Read/Write protection of Sector11 */
  553. #define OB_PCROP_SECTOR_12 0x00000001U /*!< PC Read/Write protection of Sector12 */
  554. #define OB_PCROP_SECTOR_13 0x00000002U /*!< PC Read/Write protection of Sector13 */
  555. #define OB_PCROP_SECTOR_14 0x00000004U /*!< PC Read/Write protection of Sector14 */
  556. #define OB_PCROP_SECTOR_15 0x00000008U /*!< PC Read/Write protection of Sector15 */
  557. #define OB_PCROP_SECTOR_16 0x00000010U /*!< PC Read/Write protection of Sector16 */
  558. #define OB_PCROP_SECTOR_17 0x00000020U /*!< PC Read/Write protection of Sector17 */
  559. #define OB_PCROP_SECTOR_18 0x00000040U /*!< PC Read/Write protection of Sector18 */
  560. #define OB_PCROP_SECTOR_19 0x00000080U /*!< PC Read/Write protection of Sector19 */
  561. #define OB_PCROP_SECTOR_20 0x00000100U /*!< PC Read/Write protection of Sector20 */
  562. #define OB_PCROP_SECTOR_21 0x00000200U /*!< PC Read/Write protection of Sector21 */
  563. #define OB_PCROP_SECTOR_22 0x00000400U /*!< PC Read/Write protection of Sector22 */
  564. #define OB_PCROP_SECTOR_23 0x00000800U /*!< PC Read/Write protection of Sector23 */
  565. #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */
  566. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  567. /*-----------------------------------------------------------------------------------------------------*/
  568. /*------------------------------------- STM32F413xx/STM32F423xx ---------------------------------------*/
  569. #if defined(STM32F413xx) || defined(STM32F423xx)
  570. #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
  571. #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
  572. #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
  573. #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
  574. #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
  575. #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */
  576. #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */
  577. #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */
  578. #define OB_PCROP_SECTOR_8 0x00000100U /*!< PC Read/Write protection of Sector8 */
  579. #define OB_PCROP_SECTOR_9 0x00000200U /*!< PC Read/Write protection of Sector9 */
  580. #define OB_PCROP_SECTOR_10 0x00000400U /*!< PC Read/Write protection of Sector10 */
  581. #define OB_PCROP_SECTOR_11 0x00000800U /*!< PC Read/Write protection of Sector11 */
  582. #define OB_PCROP_SECTOR_12 0x00001000U /*!< PC Read/Write protection of Sector12 */
  583. #define OB_PCROP_SECTOR_13 0x00002000U /*!< PC Read/Write protection of Sector13 */
  584. #define OB_PCROP_SECTOR_14 0x00004000U /*!< PC Read/Write protection of Sector14 */
  585. #define OB_PCROP_SECTOR_15 0x00004000U /*!< PC Read/Write protection of Sector15 */
  586. #define OB_PCROP_SECTOR_All 0x00007FFFU /*!< PC Read/Write protection of all Sectors */
  587. #endif /* STM32F413xx || STM32F423xx */
  588. /*-----------------------------------------------------------------------------------------------------*/
  589. /*--------------------------------------------- STM32F401xC -------------------------------------------*/
  590. #if defined(STM32F401xC)
  591. #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
  592. #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
  593. #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
  594. #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
  595. #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
  596. #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */
  597. #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */
  598. #endif /* STM32F401xC */
  599. /*-----------------------------------------------------------------------------------------------------*/
  600. /*--------------------------------------------- STM32F410xx -------------------------------------------*/
  601. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  602. #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
  603. #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
  604. #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
  605. #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
  606. #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
  607. #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */
  608. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  609. /*-----------------------------------------------------------------------------------------------------*/
  610. /*-------------- STM32F401xE/STM32F411xE/STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx/STM32F446xx --*/
  611. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  612. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  613. #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
  614. #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
  615. #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
  616. #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
  617. #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
  618. #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */
  619. #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */
  620. #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */
  621. #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */
  622. #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  623. /*-----------------------------------------------------------------------------------------------------*/
  624. /**
  625. * @}
  626. */
  627. /** @defgroup FLASHEx_Dual_Boot FLASH Dual Boot
  628. * @{
  629. */
  630. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  631. defined(STM32F469xx) || defined(STM32F479xx)
  632. #define OB_DUAL_BOOT_ENABLE ((uint8_t)0x10) /*!< Dual Bank Boot Enable */
  633. #define OB_DUAL_BOOT_DISABLE ((uint8_t)0x00) /*!< Dual Bank Boot Disable, always boot on User Flash */
  634. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  635. /**
  636. * @}
  637. */
  638. /** @defgroup FLASHEx_Selection_Protection_Mode FLASH Selection Protection Mode
  639. * @{
  640. */
  641. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  642. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  643. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  644. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  645. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  646. #define OB_PCROP_DESELECTED ((uint8_t)0x00) /*!< Disabled PcROP, nWPRi bits used for Write Protection on sector i */
  647. #define OB_PCROP_SELECTED ((uint8_t)0x80) /*!< Enable PcROP, nWPRi bits used for PCRoP Protection on sector i */
  648. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  649. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  650. STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  651. /**
  652. * @}
  653. */
  654. /**
  655. * @}
  656. */
  657. /* Exported macro ------------------------------------------------------------*/
  658. /* Exported functions --------------------------------------------------------*/
  659. /** @addtogroup FLASHEx_Exported_Functions
  660. * @{
  661. */
  662. /** @addtogroup FLASHEx_Exported_Functions_Group1
  663. * @{
  664. */
  665. /* Extension Program operation functions *************************************/
  666. HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError);
  667. HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
  668. HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
  669. void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
  670. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  671. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  672. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  673. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  674. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  675. HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram (FLASH_AdvOBProgramInitTypeDef *pAdvOBInit);
  676. void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit);
  677. HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void);
  678. HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void);
  679. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  680. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  681. STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  682. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  683. defined(STM32F469xx) || defined(STM32F479xx)
  684. uint16_t HAL_FLASHEx_OB_GetBank2WRP(void);
  685. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  686. /**
  687. * @}
  688. */
  689. /**
  690. * @}
  691. */
  692. /* Private types -------------------------------------------------------------*/
  693. /* Private variables ---------------------------------------------------------*/
  694. /* Private constants ---------------------------------------------------------*/
  695. /** @defgroup FLASHEx_Private_Constants FLASH Private Constants
  696. * @{
  697. */
  698. /*--------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx---------------------*/
  699. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  700. #define FLASH_SECTOR_TOTAL 24U
  701. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  702. /*-------------------------------------- STM32F413xx/STM32F423xx ---------------------------------------*/
  703. #if defined(STM32F413xx) || defined(STM32F423xx)
  704. #define FLASH_SECTOR_TOTAL 16U
  705. #endif /* STM32F413xx || STM32F423xx */
  706. /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
  707. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  708. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  709. #define FLASH_SECTOR_TOTAL 12U
  710. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  711. /*--------------------------------------------- STM32F401xC -------------------------------------------*/
  712. #if defined(STM32F401xC)
  713. #define FLASH_SECTOR_TOTAL 6U
  714. #endif /* STM32F401xC */
  715. /*--------------------------------------------- STM32F410xx -------------------------------------------*/
  716. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  717. #define FLASH_SECTOR_TOTAL 5U
  718. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  719. /*--------------------------------- STM32F401xE/STM32F411xE/STM32F412xG/STM32F446xx -------------------*/
  720. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  721. #define FLASH_SECTOR_TOTAL 8U
  722. #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
  723. /**
  724. * @brief OPTCR1 register byte 2 (Bits[23:16]) base address
  725. */
  726. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  727. #define OPTCR1_BYTE2_ADDRESS 0x40023C1AU
  728. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  729. /**
  730. * @}
  731. */
  732. /* Private macros ------------------------------------------------------------*/
  733. /** @defgroup FLASHEx_Private_Macros FLASH Private Macros
  734. * @{
  735. */
  736. /** @defgroup FLASHEx_IS_FLASH_Definitions FLASH Private macros to check input parameters
  737. * @{
  738. */
  739. #define IS_FLASH_TYPEERASE(VALUE)(((VALUE) == FLASH_TYPEERASE_SECTORS) || \
  740. ((VALUE) == FLASH_TYPEERASE_MASSERASE))
  741. #define IS_VOLTAGERANGE(RANGE)(((RANGE) == FLASH_VOLTAGE_RANGE_1) || \
  742. ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \
  743. ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \
  744. ((RANGE) == FLASH_VOLTAGE_RANGE_4))
  745. #define IS_WRPSTATE(VALUE)(((VALUE) == OB_WRPSTATE_DISABLE) || \
  746. ((VALUE) == OB_WRPSTATE_ENABLE))
  747. #define IS_OPTIONBYTE(VALUE)(((VALUE) <= (OPTIONBYTE_WRP|OPTIONBYTE_RDP|OPTIONBYTE_USER|OPTIONBYTE_BOR)))
  748. #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
  749. ((LEVEL) == OB_RDP_LEVEL_1) ||\
  750. ((LEVEL) == OB_RDP_LEVEL_2))
  751. #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
  752. #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
  753. #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
  754. #define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
  755. ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
  756. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  757. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  758. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  759. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  760. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  761. #define IS_PCROPSTATE(VALUE)(((VALUE) == OB_PCROP_STATE_DISABLE) || \
  762. ((VALUE) == OB_PCROP_STATE_ENABLE))
  763. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  764. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  765. STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  766. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  767. defined(STM32F469xx) || defined(STM32F479xx)
  768. #define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP) || \
  769. ((VALUE) == OPTIONBYTE_BOOTCONFIG))
  770. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  771. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  772. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  773. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
  774. defined(STM32F423xx)
  775. #define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP))
  776. #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx ||\
  777. STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  778. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  779. defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  780. #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
  781. ((LATENCY) == FLASH_LATENCY_1) || \
  782. ((LATENCY) == FLASH_LATENCY_2) || \
  783. ((LATENCY) == FLASH_LATENCY_3) || \
  784. ((LATENCY) == FLASH_LATENCY_4) || \
  785. ((LATENCY) == FLASH_LATENCY_5) || \
  786. ((LATENCY) == FLASH_LATENCY_6) || \
  787. ((LATENCY) == FLASH_LATENCY_7) || \
  788. ((LATENCY) == FLASH_LATENCY_8) || \
  789. ((LATENCY) == FLASH_LATENCY_9) || \
  790. ((LATENCY) == FLASH_LATENCY_10) || \
  791. ((LATENCY) == FLASH_LATENCY_11) || \
  792. ((LATENCY) == FLASH_LATENCY_12) || \
  793. ((LATENCY) == FLASH_LATENCY_13) || \
  794. ((LATENCY) == FLASH_LATENCY_14) || \
  795. ((LATENCY) == FLASH_LATENCY_15))
  796. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  797. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  798. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  799. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
  800. defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  801. #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
  802. ((LATENCY) == FLASH_LATENCY_1) || \
  803. ((LATENCY) == FLASH_LATENCY_2) || \
  804. ((LATENCY) == FLASH_LATENCY_3) || \
  805. ((LATENCY) == FLASH_LATENCY_4) || \
  806. ((LATENCY) == FLASH_LATENCY_5) || \
  807. ((LATENCY) == FLASH_LATENCY_6) || \
  808. ((LATENCY) == FLASH_LATENCY_7))
  809. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F412Zx || STM32F412Vx ||\
  810. STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  811. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  812. #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
  813. ((BANK) == FLASH_BANK_2) || \
  814. ((BANK) == FLASH_BANK_BOTH))
  815. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  816. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  817. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  818. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  819. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
  820. defined(STM32F423xx)
  821. #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1))
  822. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx ||\
  823. STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  824. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  825. #define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  826. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  827. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
  828. ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
  829. ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
  830. ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
  831. ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
  832. ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\
  833. ((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\
  834. ((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\
  835. ((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\
  836. ((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23))
  837. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  838. #if defined(STM32F413xx) || defined(STM32F423xx)
  839. #define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  840. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  841. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
  842. ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
  843. ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
  844. ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
  845. ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
  846. ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15))
  847. #endif /* STM32F413xx || STM32F423xx */
  848. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  849. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  850. #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  851. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  852. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
  853. ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
  854. ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
  855. ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11))
  856. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  857. #if defined(STM32F401xC)
  858. #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  859. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  860. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5))
  861. #endif /* STM32F401xC */
  862. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  863. #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  864. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  865. ((SECTOR) == FLASH_SECTOR_4))
  866. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  867. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  868. #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  869. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  870. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
  871. ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7))
  872. #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
  873. #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= FLASH_BASE) && ((ADDRESS) <= FLASH_END)) || \
  874. (((ADDRESS) >= FLASH_OTP_BASE) && ((ADDRESS) <= FLASH_OTP_END)))
  875. #define IS_FLASH_NBSECTORS(NBSECTORS) (((NBSECTORS) != 0) && ((NBSECTORS) <= FLASH_SECTOR_TOTAL))
  876. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  877. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFF000000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  878. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  879. #if defined(STM32F413xx) || defined(STM32F423xx)
  880. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFF8000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  881. #endif /* STM32F413xx || STM32F423xx */
  882. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  883. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  884. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  885. #if defined(STM32F401xC)
  886. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  887. #endif /* STM32F401xC */
  888. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  889. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  890. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  891. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
  892. defined(STM32F412Rx) || defined(STM32F412Cx)
  893. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  894. #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  895. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  896. #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  897. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  898. #if defined(STM32F413xx) || defined(STM32F423xx)
  899. #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFF8000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  900. #endif /* STM32F413xx || STM32F423xx */
  901. #if defined(STM32F401xC)
  902. #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  903. #endif /* STM32F401xC */
  904. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  905. #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  906. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  907. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
  908. defined(STM32F412Rx) || defined(STM32F412Cx)
  909. #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  910. #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  911. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  912. defined(STM32F469xx) || defined(STM32F479xx)
  913. #define IS_OB_BOOT(BOOT) (((BOOT) == OB_DUAL_BOOT_ENABLE) || ((BOOT) == OB_DUAL_BOOT_DISABLE))
  914. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  915. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  916. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  917. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  918. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  919. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  920. #define IS_OB_PCROP_SELECT(PCROP) (((PCROP) == OB_PCROP_SELECTED) || ((PCROP) == OB_PCROP_DESELECTED))
  921. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  922. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  923. STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  924. /**
  925. * @}
  926. */
  927. /**
  928. * @}
  929. */
  930. /* Private functions ---------------------------------------------------------*/
  931. /** @defgroup FLASHEx_Private_Functions FLASH Private Functions
  932. * @{
  933. */
  934. void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange);
  935. void FLASH_FlushCaches(void);
  936. /**
  937. * @}
  938. */
  939. /**
  940. * @}
  941. */
  942. /**
  943. * @}
  944. */
  945. #ifdef __cplusplus
  946. }
  947. #endif
  948. #endif /* __STM32F4xx_HAL_FLASH_EX_H */
  949. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/