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.
 
 

1067 rivejä
63 KiB

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