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.
 
 
 

985 lines
59 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_flash_ex.h
  4. * @author MCD Application Team
  5. * @version V1.5.2
  6. * @date 22-September-2016
  7. * @brief Header file of FLASH HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 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)
  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)
  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 */
  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 || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  122. /**
  123. * @}
  124. */
  125. /* Exported constants --------------------------------------------------------*/
  126. /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants
  127. * @{
  128. */
  129. /** @defgroup FLASHEx_Type_Erase FLASH Type Erase
  130. * @{
  131. */
  132. #define FLASH_TYPEERASE_SECTORS ((uint32_t)0x00U) /*!< Sectors erase only */
  133. #define FLASH_TYPEERASE_MASSERASE ((uint32_t)0x01U) /*!< Flash Mass erase activation */
  134. /**
  135. * @}
  136. */
  137. /** @defgroup FLASHEx_Voltage_Range FLASH Voltage Range
  138. * @{
  139. */
  140. #define FLASH_VOLTAGE_RANGE_1 ((uint32_t)0x00U) /*!< Device operating range: 1.8V to 2.1V */
  141. #define FLASH_VOLTAGE_RANGE_2 ((uint32_t)0x01U) /*!< Device operating range: 2.1V to 2.7V */
  142. #define FLASH_VOLTAGE_RANGE_3 ((uint32_t)0x02U) /*!< Device operating range: 2.7V to 3.6V */
  143. #define FLASH_VOLTAGE_RANGE_4 ((uint32_t)0x03U) /*!< Device operating range: 2.7V to 3.6V + External Vpp */
  144. /**
  145. * @}
  146. */
  147. /** @defgroup FLASHEx_WRP_State FLASH WRP State
  148. * @{
  149. */
  150. #define OB_WRPSTATE_DISABLE ((uint32_t)0x00U) /*!< Disable the write protection of the desired bank 1 sectors */
  151. #define OB_WRPSTATE_ENABLE ((uint32_t)0x01U) /*!< Enable the write protection of the desired bank 1 sectors */
  152. /**
  153. * @}
  154. */
  155. /** @defgroup FLASHEx_Option_Type FLASH Option Type
  156. * @{
  157. */
  158. #define OPTIONBYTE_WRP ((uint32_t)0x01U) /*!< WRP option byte configuration */
  159. #define OPTIONBYTE_RDP ((uint32_t)0x02U) /*!< RDP option byte configuration */
  160. #define OPTIONBYTE_USER ((uint32_t)0x04U) /*!< USER option byte configuration */
  161. #define OPTIONBYTE_BOR ((uint32_t)0x08U) /*!< BOR option byte configuration */
  162. /**
  163. * @}
  164. */
  165. /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASH Option Bytes Read Protection
  166. * @{
  167. */
  168. #define OB_RDP_LEVEL_0 ((uint8_t)0xAAU)
  169. #define OB_RDP_LEVEL_1 ((uint8_t)0x55U)
  170. #define OB_RDP_LEVEL_2 ((uint8_t)0xCCU) /*!< Warning: When enabling read protection level 2
  171. it s no more possible to go back to level 1 or 0 */
  172. /**
  173. * @}
  174. */
  175. /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASH Option Bytes IWatchdog
  176. * @{
  177. */
  178. #define OB_IWDG_SW ((uint8_t)0x20U) /*!< Software IWDG selected */
  179. #define OB_IWDG_HW ((uint8_t)0x00U) /*!< Hardware IWDG selected */
  180. /**
  181. * @}
  182. */
  183. /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASH Option Bytes nRST_STOP
  184. * @{
  185. */
  186. #define OB_STOP_NO_RST ((uint8_t)0x40U) /*!< No reset generated when entering in STOP */
  187. #define OB_STOP_RST ((uint8_t)0x00U) /*!< Reset generated when entering in STOP */
  188. /**
  189. * @}
  190. */
  191. /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASH Option Bytes nRST_STDBY
  192. * @{
  193. */
  194. #define OB_STDBY_NO_RST ((uint8_t)0x80U) /*!< No reset generated when entering in STANDBY */
  195. #define OB_STDBY_RST ((uint8_t)0x00U) /*!< Reset generated when entering in STANDBY */
  196. /**
  197. * @}
  198. */
  199. /** @defgroup FLASHEx_BOR_Reset_Level FLASH BOR Reset Level
  200. * @{
  201. */
  202. #define OB_BOR_LEVEL3 ((uint8_t)0x00U) /*!< Supply voltage ranges from 2.70 to 3.60 V */
  203. #define OB_BOR_LEVEL2 ((uint8_t)0x04U) /*!< Supply voltage ranges from 2.40 to 2.70 V */
  204. #define OB_BOR_LEVEL1 ((uint8_t)0x08U) /*!< Supply voltage ranges from 2.10 to 2.40 V */
  205. #define OB_BOR_OFF ((uint8_t)0x0CU) /*!< Supply voltage ranges from 1.62 to 2.10 V */
  206. /**
  207. * @}
  208. */
  209. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  210. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  211. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  212. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  213. defined(STM32F412Cx)
  214. /** @defgroup FLASHEx_PCROP_State FLASH PCROP State
  215. * @{
  216. */
  217. #define OB_PCROP_STATE_DISABLE ((uint32_t)0x00U) /*!< Disable PCROP */
  218. #define OB_PCROP_STATE_ENABLE ((uint32_t)0x01U) /*!< Enable PCROP */
  219. /**
  220. * @}
  221. */
  222. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  223. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  224. STM32F412Vx) || defined(STM32F412Rx) ||\
  225. STM32F412Cx */
  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 ((uint32_t)0x01U) /*!< PCROP option byte configuration */
  232. #define OPTIONBYTE_BOOTCONFIG ((uint32_t)0x02U) /*!< 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)
  237. #define OPTIONBYTE_PCROP ((uint32_t)0x01U) /*!<PCROP option byte configuration */
  238. #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  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 -----------------------------------*/
  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)
  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. /*--------------------------------------------------------------------------------------------------------------*/
  281. /**
  282. * @}
  283. */
  284. /** @defgroup FLASHEx_Banks FLASH Banks
  285. * @{
  286. */
  287. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  288. defined(STM32F469xx) || defined(STM32F479xx)
  289. #define FLASH_BANK_1 ((uint32_t)1U) /*!< Bank 1 */
  290. #define FLASH_BANK_2 ((uint32_t)2U) /*!< Bank 2 */
  291. #define FLASH_BANK_BOTH ((uint32_t)FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2 */
  292. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  293. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  294. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  295. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  296. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  297. #define FLASH_BANK_1 ((uint32_t)1U) /*!< Bank 1 */
  298. #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  299. /**
  300. * @}
  301. */
  302. /** @defgroup FLASHEx_MassErase_bit FLASH Mass Erase bit
  303. * @{
  304. */
  305. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  306. defined(STM32F469xx) || defined(STM32F479xx)
  307. #define FLASH_MER_BIT (FLASH_CR_MER1 | FLASH_CR_MER2) /*!< 2 MER bits here to clear */
  308. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  309. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  310. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  311. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  312. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  313. #define FLASH_MER_BIT (FLASH_CR_MER) /*!< only 1 MER Bit */
  314. #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  315. /**
  316. * @}
  317. */
  318. /** @defgroup FLASHEx_Sectors FLASH Sectors
  319. * @{
  320. */
  321. /*-------------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx ------------------------------------*/
  322. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  323. defined(STM32F469xx) || defined(STM32F479xx)
  324. #define FLASH_SECTOR_0 ((uint32_t)0U) /*!< Sector Number 0 */
  325. #define FLASH_SECTOR_1 ((uint32_t)1U) /*!< Sector Number 1 */
  326. #define FLASH_SECTOR_2 ((uint32_t)2U) /*!< Sector Number 2 */
  327. #define FLASH_SECTOR_3 ((uint32_t)3U) /*!< Sector Number 3 */
  328. #define FLASH_SECTOR_4 ((uint32_t)4U) /*!< Sector Number 4 */
  329. #define FLASH_SECTOR_5 ((uint32_t)5U) /*!< Sector Number 5 */
  330. #define FLASH_SECTOR_6 ((uint32_t)6U) /*!< Sector Number 6 */
  331. #define FLASH_SECTOR_7 ((uint32_t)7U) /*!< Sector Number 7 */
  332. #define FLASH_SECTOR_8 ((uint32_t)8U) /*!< Sector Number 8 */
  333. #define FLASH_SECTOR_9 ((uint32_t)9U) /*!< Sector Number 9 */
  334. #define FLASH_SECTOR_10 ((uint32_t)10U) /*!< Sector Number 10 */
  335. #define FLASH_SECTOR_11 ((uint32_t)11U) /*!< Sector Number 11 */
  336. #define FLASH_SECTOR_12 ((uint32_t)12U) /*!< Sector Number 12 */
  337. #define FLASH_SECTOR_13 ((uint32_t)13U) /*!< Sector Number 13 */
  338. #define FLASH_SECTOR_14 ((uint32_t)14U) /*!< Sector Number 14 */
  339. #define FLASH_SECTOR_15 ((uint32_t)15U) /*!< Sector Number 15 */
  340. #define FLASH_SECTOR_16 ((uint32_t)16U) /*!< Sector Number 16 */
  341. #define FLASH_SECTOR_17 ((uint32_t)17U) /*!< Sector Number 17 */
  342. #define FLASH_SECTOR_18 ((uint32_t)18U) /*!< Sector Number 18 */
  343. #define FLASH_SECTOR_19 ((uint32_t)19U) /*!< Sector Number 19 */
  344. #define FLASH_SECTOR_20 ((uint32_t)20U) /*!< Sector Number 20 */
  345. #define FLASH_SECTOR_21 ((uint32_t)21U) /*!< Sector Number 21 */
  346. #define FLASH_SECTOR_22 ((uint32_t)22U) /*!< Sector Number 22 */
  347. #define FLASH_SECTOR_23 ((uint32_t)23U) /*!< Sector Number 23 */
  348. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  349. /*-----------------------------------------------------------------------------------------------------*/
  350. /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
  351. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  352. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  353. #define FLASH_SECTOR_0 ((uint32_t)0U) /*!< Sector Number 0 */
  354. #define FLASH_SECTOR_1 ((uint32_t)1U) /*!< Sector Number 1 */
  355. #define FLASH_SECTOR_2 ((uint32_t)2U) /*!< Sector Number 2 */
  356. #define FLASH_SECTOR_3 ((uint32_t)3U) /*!< Sector Number 3 */
  357. #define FLASH_SECTOR_4 ((uint32_t)4U) /*!< Sector Number 4 */
  358. #define FLASH_SECTOR_5 ((uint32_t)5U) /*!< Sector Number 5 */
  359. #define FLASH_SECTOR_6 ((uint32_t)6U) /*!< Sector Number 6 */
  360. #define FLASH_SECTOR_7 ((uint32_t)7U) /*!< Sector Number 7 */
  361. #define FLASH_SECTOR_8 ((uint32_t)8U) /*!< Sector Number 8 */
  362. #define FLASH_SECTOR_9 ((uint32_t)9U) /*!< Sector Number 9 */
  363. #define FLASH_SECTOR_10 ((uint32_t)10U) /*!< Sector Number 10 */
  364. #define FLASH_SECTOR_11 ((uint32_t)11U) /*!< Sector Number 11 */
  365. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  366. /*-----------------------------------------------------------------------------------------------------*/
  367. /*--------------------------------------------- STM32F401xC -------------------------------------------*/
  368. #if defined(STM32F401xC)
  369. #define FLASH_SECTOR_0 ((uint32_t)0U) /*!< Sector Number 0 */
  370. #define FLASH_SECTOR_1 ((uint32_t)1U) /*!< Sector Number 1 */
  371. #define FLASH_SECTOR_2 ((uint32_t)2U) /*!< Sector Number 2 */
  372. #define FLASH_SECTOR_3 ((uint32_t)3U) /*!< Sector Number 3 */
  373. #define FLASH_SECTOR_4 ((uint32_t)4U) /*!< Sector Number 4 */
  374. #define FLASH_SECTOR_5 ((uint32_t)5U) /*!< Sector Number 5 */
  375. #endif /* STM32F401xC */
  376. /*-----------------------------------------------------------------------------------------------------*/
  377. /*--------------------------------------------- STM32F410xx -------------------------------------------*/
  378. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  379. #define FLASH_SECTOR_0 ((uint32_t)0U) /*!< Sector Number 0 */
  380. #define FLASH_SECTOR_1 ((uint32_t)1U) /*!< Sector Number 1 */
  381. #define FLASH_SECTOR_2 ((uint32_t)2U) /*!< Sector Number 2 */
  382. #define FLASH_SECTOR_3 ((uint32_t)3U) /*!< Sector Number 3 */
  383. #define FLASH_SECTOR_4 ((uint32_t)4U) /*!< Sector Number 4 */
  384. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  385. /*-----------------------------------------------------------------------------------------------------*/
  386. /*---------------------------------- STM32F401xE/STM32F411xE/STM32F446xx ------------------------------*/
  387. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  388. #define FLASH_SECTOR_0 ((uint32_t)0U) /*!< Sector Number 0 */
  389. #define FLASH_SECTOR_1 ((uint32_t)1U) /*!< Sector Number 1 */
  390. #define FLASH_SECTOR_2 ((uint32_t)2U) /*!< Sector Number 2 */
  391. #define FLASH_SECTOR_3 ((uint32_t)3U) /*!< Sector Number 3 */
  392. #define FLASH_SECTOR_4 ((uint32_t)4U) /*!< Sector Number 4 */
  393. #define FLASH_SECTOR_5 ((uint32_t)5U) /*!< Sector Number 5 */
  394. #define FLASH_SECTOR_6 ((uint32_t)6U) /*!< Sector Number 6 */
  395. #define FLASH_SECTOR_7 ((uint32_t)7U) /*!< Sector Number 7 */
  396. #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
  397. /*-----------------------------------------------------------------------------------------------------*/
  398. /**
  399. * @}
  400. */
  401. /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
  402. * @{
  403. */
  404. /*--------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx -------------------------*/
  405. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  406. defined(STM32F469xx) || defined(STM32F479xx)
  407. #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001U) /*!< Write protection of Sector0 */
  408. #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002U) /*!< Write protection of Sector1 */
  409. #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004U) /*!< Write protection of Sector2 */
  410. #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008U) /*!< Write protection of Sector3 */
  411. #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010U) /*!< Write protection of Sector4 */
  412. #define OB_WRP_SECTOR_5 ((uint32_t)0x00000020U) /*!< Write protection of Sector5 */
  413. #define OB_WRP_SECTOR_6 ((uint32_t)0x00000040U) /*!< Write protection of Sector6 */
  414. #define OB_WRP_SECTOR_7 ((uint32_t)0x00000080U) /*!< Write protection of Sector7 */
  415. #define OB_WRP_SECTOR_8 ((uint32_t)0x00000100U) /*!< Write protection of Sector8 */
  416. #define OB_WRP_SECTOR_9 ((uint32_t)0x00000200U) /*!< Write protection of Sector9 */
  417. #define OB_WRP_SECTOR_10 ((uint32_t)0x00000400U) /*!< Write protection of Sector10 */
  418. #define OB_WRP_SECTOR_11 ((uint32_t)0x00000800U) /*!< Write protection of Sector11 */
  419. #define OB_WRP_SECTOR_12 ((uint32_t)0x00000001U << 12) /*!< Write protection of Sector12 */
  420. #define OB_WRP_SECTOR_13 ((uint32_t)0x00000002U << 12) /*!< Write protection of Sector13 */
  421. #define OB_WRP_SECTOR_14 ((uint32_t)0x00000004U << 12) /*!< Write protection of Sector14 */
  422. #define OB_WRP_SECTOR_15 ((uint32_t)0x00000008U << 12) /*!< Write protection of Sector15 */
  423. #define OB_WRP_SECTOR_16 ((uint32_t)0x00000010U << 12) /*!< Write protection of Sector16 */
  424. #define OB_WRP_SECTOR_17 ((uint32_t)0x00000020U << 12) /*!< Write protection of Sector17 */
  425. #define OB_WRP_SECTOR_18 ((uint32_t)0x00000040U << 12) /*!< Write protection of Sector18 */
  426. #define OB_WRP_SECTOR_19 ((uint32_t)0x00000080U << 12) /*!< Write protection of Sector19 */
  427. #define OB_WRP_SECTOR_20 ((uint32_t)0x00000100U << 12) /*!< Write protection of Sector20 */
  428. #define OB_WRP_SECTOR_21 ((uint32_t)0x00000200U << 12) /*!< Write protection of Sector21 */
  429. #define OB_WRP_SECTOR_22 ((uint32_t)0x00000400U << 12) /*!< Write protection of Sector22 */
  430. #define OB_WRP_SECTOR_23 ((uint32_t)0x00000800U << 12) /*!< Write protection of Sector23 */
  431. #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFFU << 12) /*!< Write protection of all Sectors */
  432. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  433. /*-----------------------------------------------------------------------------------------------------*/
  434. /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
  435. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  436. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  437. #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001U) /*!< Write protection of Sector0 */
  438. #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002U) /*!< Write protection of Sector1 */
  439. #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004U) /*!< Write protection of Sector2 */
  440. #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008U) /*!< Write protection of Sector3 */
  441. #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010U) /*!< Write protection of Sector4 */
  442. #define OB_WRP_SECTOR_5 ((uint32_t)0x00000020U) /*!< Write protection of Sector5 */
  443. #define OB_WRP_SECTOR_6 ((uint32_t)0x00000040U) /*!< Write protection of Sector6 */
  444. #define OB_WRP_SECTOR_7 ((uint32_t)0x00000080U) /*!< Write protection of Sector7 */
  445. #define OB_WRP_SECTOR_8 ((uint32_t)0x00000100U) /*!< Write protection of Sector8 */
  446. #define OB_WRP_SECTOR_9 ((uint32_t)0x00000200U) /*!< Write protection of Sector9 */
  447. #define OB_WRP_SECTOR_10 ((uint32_t)0x00000400U) /*!< Write protection of Sector10 */
  448. #define OB_WRP_SECTOR_11 ((uint32_t)0x00000800U) /*!< Write protection of Sector11 */
  449. #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFFU) /*!< Write protection of all Sectors */
  450. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  451. /*-----------------------------------------------------------------------------------------------------*/
  452. /*--------------------------------------------- STM32F401xC -------------------------------------------*/
  453. #if defined(STM32F401xC)
  454. #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001U) /*!< Write protection of Sector0 */
  455. #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002U) /*!< Write protection of Sector1 */
  456. #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004U) /*!< Write protection of Sector2 */
  457. #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008U) /*!< Write protection of Sector3 */
  458. #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010U) /*!< Write protection of Sector4 */
  459. #define OB_WRP_SECTOR_5 ((uint32_t)0x00000020U) /*!< Write protection of Sector5 */
  460. #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFFU) /*!< Write protection of all Sectors */
  461. #endif /* STM32F401xC */
  462. /*-----------------------------------------------------------------------------------------------------*/
  463. /*--------------------------------------------- STM32F410xx -------------------------------------------*/
  464. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  465. #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001U) /*!< Write protection of Sector0 */
  466. #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002U) /*!< Write protection of Sector1 */
  467. #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004U) /*!< Write protection of Sector2 */
  468. #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008U) /*!< Write protection of Sector3 */
  469. #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010U) /*!< Write protection of Sector4 */
  470. #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFFU) /*!< Write protection of all Sectors */
  471. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  472. /*-----------------------------------------------------------------------------------------------------*/
  473. /*---------------------------------- STM32F401xE/STM32F411xE/STM32F446xx ------------------------------*/
  474. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  475. #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001U) /*!< Write protection of Sector0 */
  476. #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002U) /*!< Write protection of Sector1 */
  477. #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004U) /*!< Write protection of Sector2 */
  478. #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008U) /*!< Write protection of Sector3 */
  479. #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010U) /*!< Write protection of Sector4 */
  480. #define OB_WRP_SECTOR_5 ((uint32_t)0x00000020U) /*!< Write protection of Sector5 */
  481. #define OB_WRP_SECTOR_6 ((uint32_t)0x00000040U) /*!< Write protection of Sector6 */
  482. #define OB_WRP_SECTOR_7 ((uint32_t)0x00000080U) /*!< Write protection of Sector7 */
  483. #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFFU) /*!< Write protection of all Sectors */
  484. #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
  485. /*-----------------------------------------------------------------------------------------------------*/
  486. /**
  487. * @}
  488. */
  489. /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASH Option Bytes PC ReadWrite Protection
  490. * @{
  491. */
  492. /*-------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx ---------------------------*/
  493. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  494. defined(STM32F469xx) || defined(STM32F479xx)
  495. #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001U) /*!< PC Read/Write protection of Sector0 */
  496. #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002U) /*!< PC Read/Write protection of Sector1 */
  497. #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004U) /*!< PC Read/Write protection of Sector2 */
  498. #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008U) /*!< PC Read/Write protection of Sector3 */
  499. #define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010U) /*!< PC Read/Write protection of Sector4 */
  500. #define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020U) /*!< PC Read/Write protection of Sector5 */
  501. #define OB_PCROP_SECTOR_6 ((uint32_t)0x00000040U) /*!< PC Read/Write protection of Sector6 */
  502. #define OB_PCROP_SECTOR_7 ((uint32_t)0x00000080U) /*!< PC Read/Write protection of Sector7 */
  503. #define OB_PCROP_SECTOR_8 ((uint32_t)0x00000100U) /*!< PC Read/Write protection of Sector8 */
  504. #define OB_PCROP_SECTOR_9 ((uint32_t)0x00000200U) /*!< PC Read/Write protection of Sector9 */
  505. #define OB_PCROP_SECTOR_10 ((uint32_t)0x00000400U) /*!< PC Read/Write protection of Sector10 */
  506. #define OB_PCROP_SECTOR_11 ((uint32_t)0x00000800U) /*!< PC Read/Write protection of Sector11 */
  507. #define OB_PCROP_SECTOR_12 ((uint32_t)0x00000001U) /*!< PC Read/Write protection of Sector12 */
  508. #define OB_PCROP_SECTOR_13 ((uint32_t)0x00000002U) /*!< PC Read/Write protection of Sector13 */
  509. #define OB_PCROP_SECTOR_14 ((uint32_t)0x00000004U) /*!< PC Read/Write protection of Sector14 */
  510. #define OB_PCROP_SECTOR_15 ((uint32_t)0x00000008U) /*!< PC Read/Write protection of Sector15 */
  511. #define OB_PCROP_SECTOR_16 ((uint32_t)0x00000010U) /*!< PC Read/Write protection of Sector16 */
  512. #define OB_PCROP_SECTOR_17 ((uint32_t)0x00000020U) /*!< PC Read/Write protection of Sector17 */
  513. #define OB_PCROP_SECTOR_18 ((uint32_t)0x00000040U) /*!< PC Read/Write protection of Sector18 */
  514. #define OB_PCROP_SECTOR_19 ((uint32_t)0x00000080U) /*!< PC Read/Write protection of Sector19 */
  515. #define OB_PCROP_SECTOR_20 ((uint32_t)0x00000100U) /*!< PC Read/Write protection of Sector20 */
  516. #define OB_PCROP_SECTOR_21 ((uint32_t)0x00000200U) /*!< PC Read/Write protection of Sector21 */
  517. #define OB_PCROP_SECTOR_22 ((uint32_t)0x00000400U) /*!< PC Read/Write protection of Sector22 */
  518. #define OB_PCROP_SECTOR_23 ((uint32_t)0x00000800U) /*!< PC Read/Write protection of Sector23 */
  519. #define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFFU) /*!< PC Read/Write protection of all Sectors */
  520. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  521. /*-----------------------------------------------------------------------------------------------------*/
  522. /*--------------------------------------------- STM32F401xC -------------------------------------------*/
  523. #if defined(STM32F401xC)
  524. #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001U) /*!< PC Read/Write protection of Sector0 */
  525. #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002U) /*!< PC Read/Write protection of Sector1 */
  526. #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004U) /*!< PC Read/Write protection of Sector2 */
  527. #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008U) /*!< PC Read/Write protection of Sector3 */
  528. #define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010U) /*!< PC Read/Write protection of Sector4 */
  529. #define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020U) /*!< PC Read/Write protection of Sector5 */
  530. #define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFFU) /*!< PC Read/Write protection of all Sectors */
  531. #endif /* STM32F401xC */
  532. /*-----------------------------------------------------------------------------------------------------*/
  533. /*--------------------------------------------- STM32F410xx -------------------------------------------*/
  534. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  535. #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001U) /*!< PC Read/Write protection of Sector0 */
  536. #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002U) /*!< PC Read/Write protection of Sector1 */
  537. #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004U) /*!< PC Read/Write protection of Sector2 */
  538. #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008U) /*!< PC Read/Write protection of Sector3 */
  539. #define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010U) /*!< PC Read/Write protection of Sector4 */
  540. #define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFFU) /*!< PC Read/Write protection of all Sectors */
  541. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  542. /*-----------------------------------------------------------------------------------------------------*/
  543. /*-------------- STM32F401xE/STM32F411xE/STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx/STM32F446xx --*/
  544. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  545. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  546. #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001U) /*!< PC Read/Write protection of Sector0 */
  547. #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002U) /*!< PC Read/Write protection of Sector1 */
  548. #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004U) /*!< PC Read/Write protection of Sector2 */
  549. #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008U) /*!< PC Read/Write protection of Sector3 */
  550. #define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010U) /*!< PC Read/Write protection of Sector4 */
  551. #define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020U) /*!< PC Read/Write protection of Sector5 */
  552. #define OB_PCROP_SECTOR_6 ((uint32_t)0x00000040U) /*!< PC Read/Write protection of Sector6 */
  553. #define OB_PCROP_SECTOR_7 ((uint32_t)0x00000080U) /*!< PC Read/Write protection of Sector7 */
  554. #define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFFU) /*!< PC Read/Write protection of all Sectors */
  555. #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  556. /*-----------------------------------------------------------------------------------------------------*/
  557. /**
  558. * @}
  559. */
  560. /** @defgroup FLASHEx_Dual_Boot FLASH Dual Boot
  561. * @{
  562. */
  563. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  564. defined(STM32F469xx) || defined(STM32F479xx)
  565. #define OB_DUAL_BOOT_ENABLE ((uint8_t)0x10U) /*!< Dual Bank Boot Enable */
  566. #define OB_DUAL_BOOT_DISABLE ((uint8_t)0x00U) /*!< Dual Bank Boot Disable, always boot on User Flash */
  567. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  568. /**
  569. * @}
  570. */
  571. /** @defgroup FLASHEx_Selection_Protection_Mode FLASH Selection Protection Mode
  572. * @{
  573. */
  574. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  575. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  576. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  577. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  578. defined(STM32F412Cx)
  579. #define OB_PCROP_DESELECTED ((uint8_t)0x00U) /*!< Disabled PcROP, nWPRi bits used for Write Protection on sector i */
  580. #define OB_PCROP_SELECTED ((uint8_t)0x80U) /*!< Enable PcROP, nWPRi bits used for PCRoP Protection on sector i */
  581. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  582. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  583. STM32F412Vx || STM32F412Rx || STM32F412Cx */
  584. /**
  585. * @}
  586. */
  587. /**
  588. * @}
  589. */
  590. /* Exported macro ------------------------------------------------------------*/
  591. /* Exported functions --------------------------------------------------------*/
  592. /** @addtogroup FLASHEx_Exported_Functions
  593. * @{
  594. */
  595. /** @addtogroup FLASHEx_Exported_Functions_Group1
  596. * @{
  597. */
  598. /* Extension Program operation functions *************************************/
  599. HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError);
  600. HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
  601. HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
  602. void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
  603. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  604. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  605. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  606. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  607. defined(STM32F412Cx)
  608. HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram (FLASH_AdvOBProgramInitTypeDef *pAdvOBInit);
  609. void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit);
  610. HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void);
  611. HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void);
  612. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  613. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  614. STM32F412Vx || STM32F412Rx || STM32F412Cx */
  615. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  616. defined(STM32F469xx) || defined(STM32F479xx)
  617. uint16_t HAL_FLASHEx_OB_GetBank2WRP(void);
  618. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  619. /**
  620. * @}
  621. */
  622. /**
  623. * @}
  624. */
  625. /* Private types -------------------------------------------------------------*/
  626. /* Private variables ---------------------------------------------------------*/
  627. /* Private constants ---------------------------------------------------------*/
  628. /** @defgroup FLASHEx_Private_Constants FLASH Private Constants
  629. * @{
  630. */
  631. /*--------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx---------------------*/
  632. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  633. #define FLASH_SECTOR_TOTAL 24U
  634. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  635. /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
  636. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  637. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  638. #define FLASH_SECTOR_TOTAL 12U
  639. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  640. /*--------------------------------------------- STM32F401xC -------------------------------------------*/
  641. #if defined(STM32F401xC)
  642. #define FLASH_SECTOR_TOTAL 6U
  643. #endif /* STM32F401xC */
  644. /*--------------------------------------------- STM32F410xx -------------------------------------------*/
  645. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  646. #define FLASH_SECTOR_TOTAL 5U
  647. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  648. /*--------------------------------- STM32F401xE/STM32F411xE/STM32F412xG/STM32F446xx -------------------*/
  649. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  650. #define FLASH_SECTOR_TOTAL 8U
  651. #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
  652. /**
  653. * @brief OPTCR1 register byte 2 (Bits[23:16]) base address
  654. */
  655. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  656. #define OPTCR1_BYTE2_ADDRESS ((uint32_t)0x40023C1AU)
  657. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  658. /**
  659. * @}
  660. */
  661. /* Private macros ------------------------------------------------------------*/
  662. /** @defgroup FLASHEx_Private_Macros FLASH Private Macros
  663. * @{
  664. */
  665. /** @defgroup FLASHEx_IS_FLASH_Definitions FLASH Private macros to check input parameters
  666. * @{
  667. */
  668. #define IS_FLASH_TYPEERASE(VALUE)(((VALUE) == FLASH_TYPEERASE_SECTORS) || \
  669. ((VALUE) == FLASH_TYPEERASE_MASSERASE))
  670. #define IS_VOLTAGERANGE(RANGE)(((RANGE) == FLASH_VOLTAGE_RANGE_1) || \
  671. ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \
  672. ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \
  673. ((RANGE) == FLASH_VOLTAGE_RANGE_4))
  674. #define IS_WRPSTATE(VALUE)(((VALUE) == OB_WRPSTATE_DISABLE) || \
  675. ((VALUE) == OB_WRPSTATE_ENABLE))
  676. #define IS_OPTIONBYTE(VALUE)(((VALUE) <= (OPTIONBYTE_WRP|OPTIONBYTE_RDP|OPTIONBYTE_USER|OPTIONBYTE_BOR)))
  677. #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
  678. ((LEVEL) == OB_RDP_LEVEL_1) ||\
  679. ((LEVEL) == OB_RDP_LEVEL_2))
  680. #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
  681. #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
  682. #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
  683. #define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
  684. ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
  685. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  686. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  687. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  688. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  689. defined(STM32F412Cx)
  690. #define IS_PCROPSTATE(VALUE)(((VALUE) == OB_PCROP_STATE_DISABLE) || \
  691. ((VALUE) == OB_PCROP_STATE_ENABLE))
  692. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  693. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  694. STM32F412Vx || STM32F412Rx || STM32F412Cx */
  695. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  696. defined(STM32F469xx) || defined(STM32F479xx)
  697. #define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP) || \
  698. ((VALUE) == OPTIONBYTE_BOOTCONFIG))
  699. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  700. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  701. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  702. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  703. #define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP))
  704. #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx ||\
  705. STM32F412Vx || STM32F412Rx || STM32F412Cx */
  706. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  707. defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  708. #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
  709. ((LATENCY) == FLASH_LATENCY_1) || \
  710. ((LATENCY) == FLASH_LATENCY_2) || \
  711. ((LATENCY) == FLASH_LATENCY_3) || \
  712. ((LATENCY) == FLASH_LATENCY_4) || \
  713. ((LATENCY) == FLASH_LATENCY_5) || \
  714. ((LATENCY) == FLASH_LATENCY_6) || \
  715. ((LATENCY) == FLASH_LATENCY_7) || \
  716. ((LATENCY) == FLASH_LATENCY_8) || \
  717. ((LATENCY) == FLASH_LATENCY_9) || \
  718. ((LATENCY) == FLASH_LATENCY_10) || \
  719. ((LATENCY) == FLASH_LATENCY_11) || \
  720. ((LATENCY) == FLASH_LATENCY_12) || \
  721. ((LATENCY) == FLASH_LATENCY_13) || \
  722. ((LATENCY) == FLASH_LATENCY_14) || \
  723. ((LATENCY) == FLASH_LATENCY_15))
  724. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  725. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  726. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  727. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
  728. defined(STM32F412Rx) || defined(STM32F412Cx)
  729. #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
  730. ((LATENCY) == FLASH_LATENCY_1) || \
  731. ((LATENCY) == FLASH_LATENCY_2) || \
  732. ((LATENCY) == FLASH_LATENCY_3) || \
  733. ((LATENCY) == FLASH_LATENCY_4) || \
  734. ((LATENCY) == FLASH_LATENCY_5) || \
  735. ((LATENCY) == FLASH_LATENCY_6) || \
  736. ((LATENCY) == FLASH_LATENCY_7))
  737. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F412Zx || STM32F412Vx ||\
  738. STM32F412Rx || STM32F412Cx */
  739. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  740. #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
  741. ((BANK) == FLASH_BANK_2) || \
  742. ((BANK) == FLASH_BANK_BOTH))
  743. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  744. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  745. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  746. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
  747. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  748. #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1))
  749. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx ||\
  750. STM32F412Rx || STM32F412Cx */
  751. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  752. #define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  753. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  754. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
  755. ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
  756. ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
  757. ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
  758. ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
  759. ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\
  760. ((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\
  761. ((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\
  762. ((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\
  763. ((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23))
  764. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  765. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  766. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  767. #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  768. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  769. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
  770. ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
  771. ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
  772. ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11))
  773. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  774. #if defined(STM32F401xC)
  775. #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  776. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  777. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5))
  778. #endif /* STM32F401xC */
  779. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  780. #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  781. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  782. ((SECTOR) == FLASH_SECTOR_4))
  783. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  784. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  785. #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
  786. ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
  787. ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
  788. ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7))
  789. #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
  790. #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) <= FLASH_END))
  791. #define IS_FLASH_NBSECTORS(NBSECTORS) (((NBSECTORS) != 0) && ((NBSECTORS) <= FLASH_SECTOR_TOTAL))
  792. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  793. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFF000000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  794. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  795. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  796. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  797. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  798. #if defined(STM32F401xC)
  799. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  800. #endif /* STM32F401xC */
  801. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  802. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  803. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  804. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
  805. defined(STM32F412Rx) || defined(STM32F412Cx)
  806. #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  807. #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  808. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  809. #define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  810. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  811. #if defined(STM32F401xC)
  812. #define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  813. #endif /* STM32F401xC */
  814. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  815. #define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  816. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  817. #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
  818. defined(STM32F412Rx) || defined(STM32F412Cx)
  819. #define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
  820. #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  821. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  822. defined(STM32F469xx) || defined(STM32F479xx)
  823. #define IS_OB_BOOT(BOOT) (((BOOT) == OB_DUAL_BOOT_ENABLE) || ((BOOT) == OB_DUAL_BOOT_DISABLE))
  824. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  825. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  826. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  827. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  828. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  829. defined(STM32F412Cx)
  830. #define IS_OB_PCROP_SELECT(PCROP) (((PCROP) == OB_PCROP_SELECTED) || ((PCROP) == OB_PCROP_DESELECTED))
  831. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  832. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  833. STM32F412Vx || STM32F412Rx || STM32F412Cx */
  834. /**
  835. * @}
  836. */
  837. /**
  838. * @}
  839. */
  840. /* Private functions ---------------------------------------------------------*/
  841. /** @defgroup FLASHEx_Private_Functions FLASH Private Functions
  842. * @{
  843. */
  844. void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange);
  845. void FLASH_FlushCaches(void);
  846. /**
  847. * @}
  848. */
  849. /**
  850. * @}
  851. */
  852. /**
  853. * @}
  854. */
  855. #ifdef __cplusplus
  856. }
  857. #endif
  858. #endif /* __STM32F4xx_HAL_FLASH_EX_H */
  859. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/