]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M0_STM32F0518_IAR/Libraries/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_flash.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / CORTEX_M0_STM32F0518_IAR / Libraries / STM32F0xx_StdPeriph_Driver / inc / stm32f0xx_flash.h
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f0xx_flash.h\r
4   * @author  MCD Application Team\r
5   * @version V1.0.0RC1\r
6   * @date    27-January-2012\r
7   * @brief   This file contains all the functions prototypes for the FLASH \r
8   *          firmware library.\r
9   ******************************************************************************\r
10   * @attention\r
11   *\r
12   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
13   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
14   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
15   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
16   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
17   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
18   *\r
19   * FOR MORE INFORMATION PLEASE READ CAREFULLY THE LICENSE AGREEMENT FILE\r
20   * LOCATED IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE.\r
21   *\r
22   * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>\r
23   ******************************************************************************\r
24   */\r
25 \r
26 /* Define to prevent recursive inclusion -------------------------------------*/\r
27 #ifndef __STM32F0XX_FLASH_H\r
28 #define __STM32F0XX_FLASH_H\r
29 \r
30 #ifdef __cplusplus\r
31  extern "C" {\r
32 #endif\r
33 \r
34 /* Includes ------------------------------------------------------------------*/\r
35 #include "stm32f0xx.h"\r
36 \r
37 /** @addtogroup STM32F0xx_StdPeriph_Driver\r
38   * @{\r
39   */\r
40 \r
41 /** @addtogroup FLASH\r
42   * @{\r
43   */\r
44 \r
45 /* Exported types ------------------------------------------------------------*/\r
46 \r
47 /** \r
48   * @brief  FLASH Status\r
49   */ \r
50 typedef enum\r
51 {\r
52   FLASH_BUSY = 1,\r
53   FLASH_ERROR_WRP,\r
54   FLASH_ERROR_PROGRAM,\r
55   FLASH_COMPLETE,\r
56   FLASH_TIMEOUT\r
57 }FLASH_Status;\r
58 \r
59 /* Exported constants --------------------------------------------------------*/\r
60   \r
61 /** @defgroup FLASH_Exported_Constants\r
62   * @{\r
63   */ \r
64   \r
65 /** @defgroup FLASH_Latency \r
66   * @{\r
67   */ \r
68 #define FLASH_Latency_0                ((uint32_t)0x00000000)  /*!< FLASH Zero Latency cycle */\r
69 #define FLASH_Latency_1                FLASH_ACR_LATENCY       /*!< FLASH One Latency cycle */\r
70 \r
71 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \\r
72                                    ((LATENCY) == FLASH_Latency_1))\r
73 /**\r
74   * @}\r
75   */ \r
76 \r
77 /** @defgroup FLASH_Interrupts \r
78   * @{\r
79   */\r
80    \r
81 #define FLASH_IT_EOP                   FLASH_CR_EOPIE  /*!< End of programming interrupt source */\r
82 #define FLASH_IT_ERR                   FLASH_CR_ERRIE  /*!< Error interrupt source */\r
83 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))\r
84 /**\r
85   * @}\r
86   */ \r
87 \r
88 /** @defgroup FLASH_Address \r
89   * @{\r
90   */\r
91   \r
92 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0800FFFF))\r
93 \r
94 /**\r
95   * @}\r
96   */ \r
97 \r
98 /** @defgroup FLASH_Option_Bytes_Write_Protection \r
99   * @{\r
100   */\r
101   \r
102 \r
103 #define OB_WRP_Pages0to3               ((uint32_t)0x00000001) /* Write protection of page 0 to 3 */\r
104 #define OB_WRP_Pages4to7               ((uint32_t)0x00000002) /* Write protection of page 4 to 7 */\r
105 #define OB_WRP_Pages8to11              ((uint32_t)0x00000004) /* Write protection of page 8 to 11 */\r
106 #define OB_WRP_Pages12to15             ((uint32_t)0x00000008) /* Write protection of page 12 to 15 */\r
107 #define OB_WRP_Pages16to19             ((uint32_t)0x00000010) /* Write protection of page 16 to 19 */\r
108 #define OB_WRP_Pages20to23             ((uint32_t)0x00000020) /* Write protection of page 20 to 23 */\r
109 #define OB_WRP_Pages24to27             ((uint32_t)0x00000040) /* Write protection of page 24 to 27 */\r
110 #define OB_WRP_Pages28to31             ((uint32_t)0x00000080) /* Write protection of page 28 to 31 */\r
111 #define OB_WRP_Pages32to35             ((uint32_t)0x00000100) /* Write protection of page 32 to 35 */\r
112 #define OB_WRP_Pages36to39             ((uint32_t)0x00000200) /* Write protection of page 36 to 39 */\r
113 #define OB_WRP_Pages40to43             ((uint32_t)0x00000400) /* Write protection of page 40 to 43 */\r
114 #define OB_WRP_Pages44to47             ((uint32_t)0x00000800) /* Write protection of page 44 to 47 */\r
115 #define OB_WRP_Pages48to51             ((uint32_t)0x00001000) /* Write protection of page 48 to 51 */\r
116 #define OB_WRP_Pages52to55             ((uint32_t)0x00002000) /* Write protection of page 52 to 55 */\r
117 #define OB_WRP_Pages56to59             ((uint32_t)0x00004000) /* Write protection of page 56 to 59 */\r
118 #define OB_WRP_Pages60to63             ((uint32_t)0x00008000) /* Write protection of page 60 to 63 */\r
119 \r
120 #define OB_WRP_AllPages                ((uint32_t)0x0000FFFF) /*!< Write protection of all Sectors */\r
121 \r
122 #define IS_OB_WRP(PAGE) (((PAGE) != 0x0000000))\r
123 \r
124 /**\r
125   * @}\r
126   */\r
127 \r
128 /** @defgroup FLASH_Option_Bytes_Read_Protection \r
129   * @{\r
130   */ \r
131 \r
132 /** \r
133   * @brief  FLASH_Read Protection Level  \r
134   */ \r
135 #define OB_RDP_Level_0   ((uint8_t)0xAA)\r
136 #define OB_RDP_Level_1   ((uint8_t)0xBB)\r
137 /*#define OB_RDP_Level_2   ((uint8_t)0xCC)*/ /* Warning: When enabling read protection level 2 \r
138                                                 it's no more possible to go back to level 1 or 0 */\r
139 \r
140 #define IS_OB_RDP(LEVEL) (((LEVEL) == OB_RDP_Level_0)||\\r
141                           ((LEVEL) == OB_RDP_Level_1))/*||\\r
142                           ((LEVEL) == OB_RDP_Level_2))*/\r
143 /**\r
144   * @}\r
145   */ \r
146 \r
147 /** @defgroup FLASH_Option_Bytes_IWatchdog \r
148   * @{\r
149   */\r
150 \r
151 #define OB_IWDG_SW                     ((uint8_t)0x01)  /*!< Software IWDG selected */\r
152 #define OB_IWDG_HW                     ((uint8_t)0x00)  /*!< Hardware IWDG selected */\r
153 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))\r
154 \r
155 /**\r
156   * @}\r
157   */\r
158 \r
159 /** @defgroup FLASH_Option_Bytes_nRST_STOP \r
160   * @{\r
161   */\r
162 \r
163 #define OB_STOP_NoRST                  ((uint8_t)0x02) /*!< No reset generated when entering in STOP */\r
164 #define OB_STOP_RST                    ((uint8_t)0x00) /*!< Reset generated when entering in STOP */\r
165 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))\r
166 \r
167 /**\r
168   * @}\r
169   */\r
170 \r
171 /** @defgroup FLASH_Option_Bytes_nRST_STDBY \r
172   * @{\r
173   */\r
174 \r
175 #define OB_STDBY_NoRST                 ((uint8_t)0x04) /*!< No reset generated when entering in STANDBY */\r
176 #define OB_STDBY_RST                   ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */\r
177 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))\r
178 \r
179 /**\r
180   * @}\r
181   */\r
182 \r
183 /** @defgroup FLASH_Option_Bytes_BOOT1\r
184   * @{\r
185   */\r
186 \r
187 #define OB_BOOT1_RESET                 ((uint8_t)0x00) /*!< BOOT1 Reset */\r
188 #define OB_BOOT1_SET                   ((uint8_t)0x10) /*!< BOOT1 Set */\r
189 #define IS_OB_BOOT1(BOOT1) (((BOOT1) == OB_BOOT1_RESET) || ((BOOT1) == OB_BOOT1_SET))\r
190 \r
191 /**\r
192   * @}\r
193   */\r
194 \r
195 /** @defgroup FLASH_Option_Bytes_VDDA_Analog_Monitoring\r
196   * @{\r
197   */\r
198 \r
199 #define OB_VDDA_ANALOG_ON              ((uint8_t)0x00) /*!< Analog monitoring on VDDA Power source ON */\r
200 #define OB_VDDA_ANALOG_OFF             ((uint8_t)0x20) /*!< Analog monitoring on VDDA Power source OFF */\r
201 \r
202 #define IS_OB_VDDA_ANALOG(ANALOG) (((ANALOG) == OB_VDDA_ANALOG_ON) || ((ANALOG) == OB_VDDA_ANALOG_OFF))\r
203 \r
204 /**\r
205   * @}\r
206   */    \r
207   \r
208 /** @defgroup FLASH_Flags \r
209   * @{\r
210   */ \r
211 \r
212 #define FLASH_FLAG_BSY                 FLASH_SR_BSY     /*!< FLASH Busy flag */\r
213 #define FLASH_FLAG_PGERR               FLASH_SR_PGERR   /*!< FLASH Programming error flag */\r
214 #define FLASH_FLAG_WRPERR              FLASH_SR_WRPERR  /*!< FLASH Write protected error flag */\r
215 #define FLASH_FLAG_EOP                 FLASH_SR_EOP     /*!< FLASH End of Programming flag */\r
216  \r
217 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFC3) == 0x00000000) && ((FLAG) != 0x00000000))\r
218 \r
219 #define IS_FLASH_GET_FLAG(FLAG)  (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_PGERR) || \\r
220                                   ((FLAG) == FLASH_FLAG_WRPERR) || ((FLAG) == FLASH_FLAG_EOP))\r
221 /**\r
222   * @}\r
223   */ \r
224 \r
225 /** @defgroup FLASH_Keys \r
226   * @{\r
227   */ \r
228 \r
229 #define FLASH_FKEY1                ((uint32_t)0x45670123) /*!< Flash program erase key1 */\r
230 #define FLASH_FKEY2                ((uint32_t)0xCDEF89AB) /*!< Flash program erase key: used with FLASH_PEKEY1\r
231                                                                to unlock the write access to the FPEC. */\r
232                                                                \r
233 #define FLASH_OPTKEY1              ((uint32_t)0x45670123) /*!< Flash option key1 */\r
234 #define FLASH_OPTKEY2              ((uint32_t)0xCDEF89AB) /*!< Flash option key2: used with FLASH_OPTKEY1 to\r
235                                                                unlock the write access to the option byte block */\r
236 /**\r
237   * @}\r
238   */\r
239   \r
240 /** @defgroup FLASH_Timeout_definition \r
241   * @{\r
242   */ \r
243 #define FLASH_ER_PRG_TIMEOUT         ((uint32_t)0x000B0000)\r
244 \r
245 /**\r
246   * @}\r
247   */ \r
248 \r
249 /**\r
250   * @}\r
251   */ \r
252 \r
253 /* Exported macro ------------------------------------------------------------*/\r
254 /* Exported functions ------------------------------------------------------- */\r
255   \r
256 /** \r
257   * @brief  FLASH memory functions that can be executed from FLASH.  \r
258   */  \r
259 /* FLASH Interface configuration functions ************************************/\r
260 void FLASH_SetLatency(uint32_t FLASH_Latency);\r
261 void FLASH_PrefetchBufferCmd(FunctionalState NewState);\r
262 FlagStatus FLASH_GetPrefetchBufferStatus(void);\r
263 \r
264 /* FLASH Memory Programming functions *****************************************/\r
265 void FLASH_Unlock(void);\r
266 void FLASH_Lock(void);\r
267 FLASH_Status FLASH_ErasePage(uint32_t Page_Address);\r
268 FLASH_Status FLASH_EraseAllPages(void);\r
269 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);\r
270 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);\r
271 \r
272 /* FLASH Option Bytes Programming functions *****************************************/\r
273 void FLASH_OB_Unlock(void);\r
274 void FLASH_OB_Lock(void);\r
275 void FLASH_OB_Launch(void);\r
276 FLASH_Status FLASH_OB_Erase(void);\r
277 FLASH_Status FLASH_OB_EnableWRP(uint32_t OB_WRP);\r
278 FLASH_Status FLASH_OB_RDPConfig(uint8_t OB_RDP);\r
279 FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY);\r
280 FLASH_Status FLASH_OB_BOOTConfig(uint8_t OB_BOOT1);\r
281 FLASH_Status FLASH_OB_VDDAConfig(uint8_t OB_VDDA_ANALOG);\r
282 FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER);\r
283 uint8_t FLASH_OB_GetUser(void);\r
284 uint32_t FLASH_OB_GetWRP(void);\r
285 FlagStatus FLASH_OB_GetRDP(void);\r
286 \r
287 /* FLASH Interrupts and flags management functions **********************************/\r
288 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);\r
289 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);\r
290 void FLASH_ClearFlag(uint32_t FLASH_FLAG);\r
291 FLASH_Status FLASH_GetStatus(void);\r
292 FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);\r
293 \r
294 #ifdef __cplusplus\r
295 }\r
296 #endif\r
297 \r
298 #endif /* __STM32F0XX_FLASH_H */\r
299 \r
300 /**\r
301   * @}\r
302   */\r
303 \r
304 /**\r
305   * @}\r
306   */ \r
307 \r
308 /******************* (C) COPYRIGHT 2012 STMicroelectronics *****END OF FILE****/\r