You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1085 lines
64 KiB

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