A bundled STM32F10x Std Periph and CMSIS library
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.

stm32f10x_flash.h 25 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. /**
  2. ******************************************************************************
  3. * @file stm32f10x_flash.h
  4. * @author MCD Application Team
  5. * @version V3.5.0
  6. * @date 11-March-2011
  7. * @brief This file contains all the functions prototypes for the FLASH
  8. * firmware library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  13. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  14. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  15. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  16. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  17. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  18. *
  19. * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  20. ******************************************************************************
  21. */
  22. /* Define to prevent recursive inclusion -------------------------------------*/
  23. #ifndef __STM32F10x_FLASH_H
  24. #define __STM32F10x_FLASH_H
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* Includes ------------------------------------------------------------------*/
  29. #include "stm32f10x.h"
  30. #include "stm32f10x_assert.h"
  31. /** @addtogroup STM32F10x_StdPeriph_Driver
  32. * @{
  33. */
  34. /** @addtogroup FLASH
  35. * @{
  36. */
  37. /** @defgroup FLASH_Exported_Types
  38. * @{
  39. */
  40. /**
  41. * @brief FLASH Status
  42. */
  43. typedef enum
  44. {
  45. FLASH_COMPLETE=0, /*!< This is 0, so any cast to int will work as well */
  46. FLASH_BUSY = 1,
  47. FLASH_ERROR_PG,
  48. FLASH_ERROR_WRP,
  49. FLASH_TIMEOUT
  50. }FLASH_Status;
  51. /**
  52. * @}
  53. */
  54. /** @defgroup FLASH_Exported_Constants
  55. * @{
  56. */
  57. /** @defgroup Flash_Latency
  58. * @{
  59. */
  60. #define FLASH_Latency_0 ((uint32_t)0x00000000) /*!< FLASH Zero Latency cycle */
  61. #define FLASH_Latency_1 ((uint32_t)0x00000001) /*!< FLASH One Latency cycle */
  62. #define FLASH_Latency_2 ((uint32_t)0x00000002) /*!< FLASH Two Latency cycles */
  63. #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
  64. ((LATENCY) == FLASH_Latency_1) || \
  65. ((LATENCY) == FLASH_Latency_2))
  66. /**
  67. * @}
  68. */
  69. /** @defgroup Half_Cycle_Enable_Disable
  70. * @{
  71. */
  72. #define FLASH_HalfCycleAccess_Enable ((uint32_t)0x00000008) /*!< FLASH Half Cycle Enable */
  73. #define FLASH_HalfCycleAccess_Disable ((uint32_t)0x00000000) /*!< FLASH Half Cycle Disable */
  74. #define IS_FLASH_HALFCYCLEACCESS_STATE(STATE) (((STATE) == FLASH_HalfCycleAccess_Enable) || \
  75. ((STATE) == FLASH_HalfCycleAccess_Disable))
  76. /**
  77. * @}
  78. */
  79. /** @defgroup Prefetch_Buffer_Enable_Disable
  80. * @{
  81. */
  82. #define FLASH_PrefetchBuffer_Enable ((uint32_t)0x00000010) /*!< FLASH Prefetch Buffer Enable */
  83. #define FLASH_PrefetchBuffer_Disable ((uint32_t)0x00000000) /*!< FLASH Prefetch Buffer Disable */
  84. #define IS_FLASH_PREFETCHBUFFER_STATE(STATE) (((STATE) == FLASH_PrefetchBuffer_Enable) || \
  85. ((STATE) == FLASH_PrefetchBuffer_Disable))
  86. /**
  87. * @}
  88. */
  89. /** @defgroup Option_Bytes_Write_Protection
  90. * @{
  91. */
  92. /* Values to be used with STM32 Low and Medium density devices */
  93. #define FLASH_WRProt_Pages0to3 ((uint32_t)0x00000001) /*!< STM32 Low and Medium density devices: Write protection of page 0 to 3 */
  94. #define FLASH_WRProt_Pages4to7 ((uint32_t)0x00000002) /*!< STM32 Low and Medium density devices: Write protection of page 4 to 7 */
  95. #define FLASH_WRProt_Pages8to11 ((uint32_t)0x00000004) /*!< STM32 Low and Medium density devices: Write protection of page 8 to 11 */
  96. #define FLASH_WRProt_Pages12to15 ((uint32_t)0x00000008) /*!< STM32 Low and Medium density devices: Write protection of page 12 to 15 */
  97. #define FLASH_WRProt_Pages16to19 ((uint32_t)0x00000010) /*!< STM32 Low and Medium density devices: Write protection of page 16 to 19 */
  98. #define FLASH_WRProt_Pages20to23 ((uint32_t)0x00000020) /*!< STM32 Low and Medium density devices: Write protection of page 20 to 23 */
  99. #define FLASH_WRProt_Pages24to27 ((uint32_t)0x00000040) /*!< STM32 Low and Medium density devices: Write protection of page 24 to 27 */
  100. #define FLASH_WRProt_Pages28to31 ((uint32_t)0x00000080) /*!< STM32 Low and Medium density devices: Write protection of page 28 to 31 */
  101. /* Values to be used with STM32 Medium-density devices */
  102. #define FLASH_WRProt_Pages32to35 ((uint32_t)0x00000100) /*!< STM32 Medium-density devices: Write protection of page 32 to 35 */
  103. #define FLASH_WRProt_Pages36to39 ((uint32_t)0x00000200) /*!< STM32 Medium-density devices: Write protection of page 36 to 39 */
  104. #define FLASH_WRProt_Pages40to43 ((uint32_t)0x00000400) /*!< STM32 Medium-density devices: Write protection of page 40 to 43 */
  105. #define FLASH_WRProt_Pages44to47 ((uint32_t)0x00000800) /*!< STM32 Medium-density devices: Write protection of page 44 to 47 */
  106. #define FLASH_WRProt_Pages48to51 ((uint32_t)0x00001000) /*!< STM32 Medium-density devices: Write protection of page 48 to 51 */
  107. #define FLASH_WRProt_Pages52to55 ((uint32_t)0x00002000) /*!< STM32 Medium-density devices: Write protection of page 52 to 55 */
  108. #define FLASH_WRProt_Pages56to59 ((uint32_t)0x00004000) /*!< STM32 Medium-density devices: Write protection of page 56 to 59 */
  109. #define FLASH_WRProt_Pages60to63 ((uint32_t)0x00008000) /*!< STM32 Medium-density devices: Write protection of page 60 to 63 */
  110. #define FLASH_WRProt_Pages64to67 ((uint32_t)0x00010000) /*!< STM32 Medium-density devices: Write protection of page 64 to 67 */
  111. #define FLASH_WRProt_Pages68to71 ((uint32_t)0x00020000) /*!< STM32 Medium-density devices: Write protection of page 68 to 71 */
  112. #define FLASH_WRProt_Pages72to75 ((uint32_t)0x00040000) /*!< STM32 Medium-density devices: Write protection of page 72 to 75 */
  113. #define FLASH_WRProt_Pages76to79 ((uint32_t)0x00080000) /*!< STM32 Medium-density devices: Write protection of page 76 to 79 */
  114. #define FLASH_WRProt_Pages80to83 ((uint32_t)0x00100000) /*!< STM32 Medium-density devices: Write protection of page 80 to 83 */
  115. #define FLASH_WRProt_Pages84to87 ((uint32_t)0x00200000) /*!< STM32 Medium-density devices: Write protection of page 84 to 87 */
  116. #define FLASH_WRProt_Pages88to91 ((uint32_t)0x00400000) /*!< STM32 Medium-density devices: Write protection of page 88 to 91 */
  117. #define FLASH_WRProt_Pages92to95 ((uint32_t)0x00800000) /*!< STM32 Medium-density devices: Write protection of page 92 to 95 */
  118. #define FLASH_WRProt_Pages96to99 ((uint32_t)0x01000000) /*!< STM32 Medium-density devices: Write protection of page 96 to 99 */
  119. #define FLASH_WRProt_Pages100to103 ((uint32_t)0x02000000) /*!< STM32 Medium-density devices: Write protection of page 100 to 103 */
  120. #define FLASH_WRProt_Pages104to107 ((uint32_t)0x04000000) /*!< STM32 Medium-density devices: Write protection of page 104 to 107 */
  121. #define FLASH_WRProt_Pages108to111 ((uint32_t)0x08000000) /*!< STM32 Medium-density devices: Write protection of page 108 to 111 */
  122. #define FLASH_WRProt_Pages112to115 ((uint32_t)0x10000000) /*!< STM32 Medium-density devices: Write protection of page 112 to 115 */
  123. #define FLASH_WRProt_Pages116to119 ((uint32_t)0x20000000) /*!< STM32 Medium-density devices: Write protection of page 115 to 119 */
  124. #define FLASH_WRProt_Pages120to123 ((uint32_t)0x40000000) /*!< STM32 Medium-density devices: Write protection of page 120 to 123 */
  125. #define FLASH_WRProt_Pages124to127 ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 124 to 127 */
  126. /* Values to be used with STM32 High-density and STM32F10X Connectivity line devices */
  127. #define FLASH_WRProt_Pages0to1 ((uint32_t)0x00000001) /*!< STM32 High-density, XL-density and Connectivity line devices:
  128. Write protection of page 0 to 1 */
  129. #define FLASH_WRProt_Pages2to3 ((uint32_t)0x00000002) /*!< STM32 High-density, XL-density and Connectivity line devices:
  130. Write protection of page 2 to 3 */
  131. #define FLASH_WRProt_Pages4to5 ((uint32_t)0x00000004) /*!< STM32 High-density, XL-density and Connectivity line devices:
  132. Write protection of page 4 to 5 */
  133. #define FLASH_WRProt_Pages6to7 ((uint32_t)0x00000008) /*!< STM32 High-density, XL-density and Connectivity line devices:
  134. Write protection of page 6 to 7 */
  135. #define FLASH_WRProt_Pages8to9 ((uint32_t)0x00000010) /*!< STM32 High-density, XL-density and Connectivity line devices:
  136. Write protection of page 8 to 9 */
  137. #define FLASH_WRProt_Pages10to11 ((uint32_t)0x00000020) /*!< STM32 High-density, XL-density and Connectivity line devices:
  138. Write protection of page 10 to 11 */
  139. #define FLASH_WRProt_Pages12to13 ((uint32_t)0x00000040) /*!< STM32 High-density, XL-density and Connectivity line devices:
  140. Write protection of page 12 to 13 */
  141. #define FLASH_WRProt_Pages14to15 ((uint32_t)0x00000080) /*!< STM32 High-density, XL-density and Connectivity line devices:
  142. Write protection of page 14 to 15 */
  143. #define FLASH_WRProt_Pages16to17 ((uint32_t)0x00000100) /*!< STM32 High-density, XL-density and Connectivity line devices:
  144. Write protection of page 16 to 17 */
  145. #define FLASH_WRProt_Pages18to19 ((uint32_t)0x00000200) /*!< STM32 High-density, XL-density and Connectivity line devices:
  146. Write protection of page 18 to 19 */
  147. #define FLASH_WRProt_Pages20to21 ((uint32_t)0x00000400) /*!< STM32 High-density, XL-density and Connectivity line devices:
  148. Write protection of page 20 to 21 */
  149. #define FLASH_WRProt_Pages22to23 ((uint32_t)0x00000800) /*!< STM32 High-density, XL-density and Connectivity line devices:
  150. Write protection of page 22 to 23 */
  151. #define FLASH_WRProt_Pages24to25 ((uint32_t)0x00001000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  152. Write protection of page 24 to 25 */
  153. #define FLASH_WRProt_Pages26to27 ((uint32_t)0x00002000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  154. Write protection of page 26 to 27 */
  155. #define FLASH_WRProt_Pages28to29 ((uint32_t)0x00004000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  156. Write protection of page 28 to 29 */
  157. #define FLASH_WRProt_Pages30to31 ((uint32_t)0x00008000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  158. Write protection of page 30 to 31 */
  159. #define FLASH_WRProt_Pages32to33 ((uint32_t)0x00010000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  160. Write protection of page 32 to 33 */
  161. #define FLASH_WRProt_Pages34to35 ((uint32_t)0x00020000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  162. Write protection of page 34 to 35 */
  163. #define FLASH_WRProt_Pages36to37 ((uint32_t)0x00040000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  164. Write protection of page 36 to 37 */
  165. #define FLASH_WRProt_Pages38to39 ((uint32_t)0x00080000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  166. Write protection of page 38 to 39 */
  167. #define FLASH_WRProt_Pages40to41 ((uint32_t)0x00100000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  168. Write protection of page 40 to 41 */
  169. #define FLASH_WRProt_Pages42to43 ((uint32_t)0x00200000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  170. Write protection of page 42 to 43 */
  171. #define FLASH_WRProt_Pages44to45 ((uint32_t)0x00400000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  172. Write protection of page 44 to 45 */
  173. #define FLASH_WRProt_Pages46to47 ((uint32_t)0x00800000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  174. Write protection of page 46 to 47 */
  175. #define FLASH_WRProt_Pages48to49 ((uint32_t)0x01000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  176. Write protection of page 48 to 49 */
  177. #define FLASH_WRProt_Pages50to51 ((uint32_t)0x02000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  178. Write protection of page 50 to 51 */
  179. #define FLASH_WRProt_Pages52to53 ((uint32_t)0x04000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  180. Write protection of page 52 to 53 */
  181. #define FLASH_WRProt_Pages54to55 ((uint32_t)0x08000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  182. Write protection of page 54 to 55 */
  183. #define FLASH_WRProt_Pages56to57 ((uint32_t)0x10000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  184. Write protection of page 56 to 57 */
  185. #define FLASH_WRProt_Pages58to59 ((uint32_t)0x20000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  186. Write protection of page 58 to 59 */
  187. #define FLASH_WRProt_Pages60to61 ((uint32_t)0x40000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
  188. Write protection of page 60 to 61 */
  189. #define FLASH_WRProt_Pages62to127 ((uint32_t)0x80000000) /*!< STM32 Connectivity line devices: Write protection of page 62 to 127 */
  190. #define FLASH_WRProt_Pages62to255 ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 62 to 255 */
  191. #define FLASH_WRProt_Pages62to511 ((uint32_t)0x80000000) /*!< STM32 XL-density devices: Write protection of page 62 to 511 */
  192. #define FLASH_WRProt_AllPages ((uint32_t)0xFFFFFFFF) /*!< Write protection of all Pages */
  193. #define IS_FLASH_WRPROT_PAGE(PAGE) (((PAGE) != 0x00000000))
  194. #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF))
  195. #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
  196. /**
  197. * @}
  198. */
  199. /** @defgroup Option_Bytes_IWatchdog
  200. * @{
  201. */
  202. #define OB_IWDG_SW ((uint16_t)0x0001) /*!< Software IWDG selected */
  203. #define OB_IWDG_HW ((uint16_t)0x0000) /*!< Hardware IWDG selected */
  204. #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
  205. /**
  206. * @}
  207. */
  208. /** @defgroup Option_Bytes_nRST_STOP
  209. * @{
  210. */
  211. #define OB_STOP_NoRST ((uint16_t)0x0002) /*!< No reset generated when entering in STOP */
  212. #define OB_STOP_RST ((uint16_t)0x0000) /*!< Reset generated when entering in STOP */
  213. #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
  214. /**
  215. * @}
  216. */
  217. /** @defgroup Option_Bytes_nRST_STDBY
  218. * @{
  219. */
  220. #define OB_STDBY_NoRST ((uint16_t)0x0004) /*!< No reset generated when entering in STANDBY */
  221. #define OB_STDBY_RST ((uint16_t)0x0000) /*!< Reset generated when entering in STANDBY */
  222. #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
  223. #ifdef STM32F10X_XL
  224. /**
  225. * @}
  226. */
  227. /** @defgroup FLASH_Boot
  228. * @{
  229. */
  230. #define FLASH_BOOT_Bank1 ((uint16_t)0x0000) /*!< At startup, if boot pins are set in boot from user Flash position
  231. and this parameter is selected the device will boot from Bank1(Default) */
  232. #define FLASH_BOOT_Bank2 ((uint16_t)0x0001) /*!< At startup, if boot pins are set in boot from user Flash position
  233. and this parameter is selected the device will boot from Bank 2 or Bank 1,
  234. depending on the activation of the bank */
  235. #define IS_FLASH_BOOT(BOOT) (((BOOT) == FLASH_BOOT_Bank1) || ((BOOT) == FLASH_BOOT_Bank2))
  236. #endif
  237. /**
  238. * @}
  239. */
  240. /** @defgroup FLASH_Interrupts
  241. * @{
  242. */
  243. #ifdef STM32F10X_XL
  244. #define FLASH_IT_BANK2_ERROR ((uint32_t)0x80000400) /*!< FPEC BANK2 error interrupt source */
  245. #define FLASH_IT_BANK2_EOP ((uint32_t)0x80001000) /*!< End of FLASH BANK2 Operation Interrupt source */
  246. #define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR /*!< FPEC BANK1 error interrupt source */
  247. #define FLASH_IT_BANK1_EOP FLASH_IT_EOP /*!< End of FLASH BANK1 Operation Interrupt source */
  248. #define FLASH_IT_ERROR ((uint32_t)0x00000400) /*!< FPEC BANK1 error interrupt source */
  249. #define FLASH_IT_EOP ((uint32_t)0x00001000) /*!< End of FLASH BANK1 Operation Interrupt source */
  250. #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0x7FFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
  251. #else
  252. #define FLASH_IT_ERROR ((uint32_t)0x00000400) /*!< FPEC error interrupt source */
  253. #define FLASH_IT_EOP ((uint32_t)0x00001000) /*!< End of FLASH Operation Interrupt source */
  254. #define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR /*!< FPEC BANK1 error interrupt source */
  255. #define FLASH_IT_BANK1_EOP FLASH_IT_EOP /*!< End of FLASH BANK1 Operation Interrupt source */
  256. #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
  257. #endif
  258. /**
  259. * @}
  260. */
  261. /** @defgroup FLASH_Flags
  262. * @{
  263. */
  264. #ifdef STM32F10X_XL
  265. #define FLASH_FLAG_BANK2_BSY ((uint32_t)0x80000001) /*!< FLASH BANK2 Busy flag */
  266. #define FLASH_FLAG_BANK2_EOP ((uint32_t)0x80000020) /*!< FLASH BANK2 End of Operation flag */
  267. #define FLASH_FLAG_BANK2_PGERR ((uint32_t)0x80000004) /*!< FLASH BANK2 Program error flag */
  268. #define FLASH_FLAG_BANK2_WRPRTERR ((uint32_t)0x80000010) /*!< FLASH BANK2 Write protected error flag */
  269. #define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY /*!< FLASH BANK1 Busy flag*/
  270. #define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP /*!< FLASH BANK1 End of Operation flag */
  271. #define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR /*!< FLASH BANK1 Program error flag */
  272. #define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR /*!< FLASH BANK1 Write protected error flag */
  273. #define FLASH_FLAG_BSY ((uint32_t)0x00000001) /*!< FLASH Busy flag */
  274. #define FLASH_FLAG_EOP ((uint32_t)0x00000020) /*!< FLASH End of Operation flag */
  275. #define FLASH_FLAG_PGERR ((uint32_t)0x00000004) /*!< FLASH Program error flag */
  276. #define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010) /*!< FLASH Write protected error flag */
  277. #define FLASH_FLAG_OPTERR ((uint32_t)0x00000001) /*!< FLASH Option Byte error flag */
  278. #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0x7FFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
  279. #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
  280. ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
  281. ((FLAG) == FLASH_FLAG_OPTERR)|| \
  282. ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
  283. ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
  284. ((FLAG) == FLASH_FLAG_BANK2_BSY) || ((FLAG) == FLASH_FLAG_BANK2_EOP) || \
  285. ((FLAG) == FLASH_FLAG_BANK2_PGERR) || ((FLAG) == FLASH_FLAG_BANK2_WRPRTERR))
  286. #else
  287. #define FLASH_FLAG_BSY ((uint32_t)0x00000001) /*!< FLASH Busy flag */
  288. #define FLASH_FLAG_EOP ((uint32_t)0x00000020) /*!< FLASH End of Operation flag */
  289. #define FLASH_FLAG_PGERR ((uint32_t)0x00000004) /*!< FLASH Program error flag */
  290. #define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010) /*!< FLASH Write protected error flag */
  291. #define FLASH_FLAG_OPTERR ((uint32_t)0x00000001) /*!< FLASH Option Byte error flag */
  292. #define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY /*!< FLASH BANK1 Busy flag*/
  293. #define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP /*!< FLASH BANK1 End of Operation flag */
  294. #define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR /*!< FLASH BANK1 Program error flag */
  295. #define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR /*!< FLASH BANK1 Write protected error flag */
  296. #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
  297. #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
  298. ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
  299. ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
  300. ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
  301. ((FLAG) == FLASH_FLAG_OPTERR))
  302. #endif
  303. /**
  304. * @}
  305. */
  306. /**
  307. * @}
  308. */
  309. /** @defgroup FLASH_Exported_Macros
  310. * @{
  311. */
  312. /**
  313. * @}
  314. */
  315. /** @defgroup FLASH_Exported_Functions
  316. * @{
  317. */
  318. /*------------ Functions used for all STM32F10x devices -----*/
  319. void FLASH_SetLatency(uint32_t FLASH_Latency);
  320. void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess);
  321. void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer);
  322. void FLASH_Unlock(void);
  323. void FLASH_Lock(void);
  324. FLASH_Status FLASH_ErasePage(uint32_t Page_Address);
  325. FLASH_Status FLASH_EraseAllPages(void);
  326. FLASH_Status FLASH_EraseOptionBytes(void);
  327. FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
  328. FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
  329. FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data);
  330. FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages);
  331. FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState);
  332. FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY);
  333. uint32_t FLASH_GetUserOptionByte(void);
  334. uint32_t FLASH_GetWriteProtectionOptionByte(void);
  335. FlagStatus FLASH_GetReadOutProtectionStatus(void);
  336. FlagStatus FLASH_GetPrefetchBufferStatus(void);
  337. void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
  338. FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
  339. void FLASH_ClearFlag(uint32_t FLASH_FLAG);
  340. FLASH_Status FLASH_GetStatus(void);
  341. FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);
  342. /*------------ New function used for all STM32F10x devices -----*/
  343. void FLASH_UnlockBank1(void);
  344. void FLASH_LockBank1(void);
  345. FLASH_Status FLASH_EraseAllBank1Pages(void);
  346. FLASH_Status FLASH_GetBank1Status(void);
  347. FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout);
  348. #ifdef STM32F10X_XL
  349. /*---- New Functions used only with STM32F10x_XL density devices -----*/
  350. void FLASH_UnlockBank2(void);
  351. void FLASH_LockBank2(void);
  352. FLASH_Status FLASH_EraseAllBank2Pages(void);
  353. FLASH_Status FLASH_GetBank2Status(void);
  354. FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout);
  355. FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT);
  356. #endif
  357. #ifdef __cplusplus
  358. }
  359. #endif
  360. #endif /* __STM32F10x_FLASH_H */
  361. /**
  362. * @}
  363. */
  364. /**
  365. * @}
  366. */
  367. /**
  368. * @}
  369. */
  370. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/