]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_flash_ex.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F0 / stm32f0xx_hal_flash_ex.h
1 /**
2   ******************************************************************************
3   * @file    stm32f0xx_hal_flash_ex.h
4   * @author  MCD Application Team
5   * @version V1.2.0
6   * @date    11-December-2014
7   * @brief   Header file of FLASH HAL Extension module.
8   ******************************************************************************
9   * @attention
10   *
11   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
12   *
13   * Redistribution and use in source and binary forms, with or without modification,
14   * are permitted provided that the following conditions are met:
15   *   1. Redistributions of source code must retain the above copyright notice,
16   *      this list of conditions and the following disclaimer.
17   *   2. Redistributions in binary form must reproduce the above copyright notice,
18   *      this list of conditions and the following disclaimer in the documentation
19   *      and/or other materials provided with the distribution.
20   *   3. Neither the name of STMicroelectronics nor the names of its contributors
21   *      may be used to endorse or promote products derived from this software
22   *      without specific prior written permission.
23   *
24   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34   *
35   ******************************************************************************
36   */
37
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F0xx_HAL_FLASH_EX_H
40 #define __STM32F0xx_HAL_FLASH_EX_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f0xx_hal_def.h"
48
49 /** @addtogroup STM32F0xx_HAL_Driver
50   * @{
51   */
52
53 /** @addtogroup FLASHEx
54   * @{
55   */ 
56
57 /* Exported types ------------------------------------------------------------*/ 
58 /* Exported constants --------------------------------------------------------*/
59 /** @defgroup FLASHEx_Exported_Constants FLASHEx Exported Constants
60   * @{
61   */  
62 /** @defgroup FLASHEx_Address FLASHEx Address
63   * @{
64   */
65 #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F038xx) || defined(STM32F070x6)
66 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x08007FFF))
67 #endif /* STM32F030x6 || STM32F031x6 || STM32F042x6 || STM32F048xx || STM32F038xx || STM32F070x6 */
68    
69 #if defined(STM32F030x8) || defined(STM32F051x8) || defined(STM32F058xx)
70 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0800FFFF))
71 #endif /* STM32F030x8 || STM32F051x8 || STM32F058xx */
72    
73 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
74 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0801FFFF))
75 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB*/
76
77 #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
78 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0803FFFF))
79 #endif /* STM32F091xC || STM32F098xx || STM32F030xC*/
80 /**
81   * @}
82   */
83
84 /** @defgroup FLASHEx_Page_Size FLASHEx Page Size
85   * @{
86   */
87 #if defined(STM32F030x6) || defined(STM32F030x8) || defined(STM32F031x6) || defined(STM32F038xx) || \
88     defined(STM32F051x8) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F058xx) || defined(STM32F070x6)
89 #define FLASH_PAGE_SIZE          0x400
90 #endif /* STM32F030x6 || STM32F030x8 || STM32F031x6 || STM32F051x8 || STM32F042x6 || STM32F048xx || STM32F058xx || STM32F070x6 */
91
92 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
93     defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
94 #define FLASH_PAGE_SIZE          0x800
95 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F091xC || STM32F098xx || STM32F030xC */
96
97 /**
98   * @}
99   */
100
101 /** @defgroup FLASHEx_Nb_Pages FLASHEx Nb Pages
102   * @{
103   */
104 #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F038xx)|| defined(STM32F070x6)
105 #define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x08007FFF)
106 #endif /* STM32F030x6 || STM32F031x6 || STM32F042x6 || STM32F048xx || STM32F038xx || STM32F070x6 */
107
108 #if defined(STM32F030x8) || defined(STM32F051x8) || defined(STM32F058xx)
109 #define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0800FFFF)
110 #endif /* STM32F030x8 || STM32F051x8 || STM32F058xx */
111
112 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
113 #define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0801FFFF)
114 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB */
115       
116 #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
117 #define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0803FFFF)
118 #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
119 /**
120   * @}
121   */
122
123 /** @defgroup FLASHEx_OB_Write_Protection FLASHEx OB Write Protection
124   * @{
125   */
126 #if defined(STM32F030x6) || defined(STM32F030x8) || defined(STM32F031x6) || defined(STM32F038xx) || \
127     defined(STM32F051x8) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F058xx) || defined(STM32F070x6) 
128 #define OB_WRP_PAGES0TO3               ((uint32_t)0x00000001) /* Write protection of page 0 to 3 */
129 #define OB_WRP_PAGES4TO7               ((uint32_t)0x00000002) /* Write protection of page 4 to 7 */
130 #define OB_WRP_PAGES8TO11              ((uint32_t)0x00000004) /* Write protection of page 8 to 11 */
131 #define OB_WRP_PAGES12TO15             ((uint32_t)0x00000008) /* Write protection of page 12 to 15 */
132 #define OB_WRP_PAGES16TO19             ((uint32_t)0x00000010) /* Write protection of page 16 to 19 */
133 #define OB_WRP_PAGES20TO23             ((uint32_t)0x00000020) /* Write protection of page 20 to 23 */
134 #define OB_WRP_PAGES24TO27             ((uint32_t)0x00000040) /* Write protection of page 24 to 27 */
135 #define OB_WRP_PAGES28TO31             ((uint32_t)0x00000080) /* Write protection of page 28 to 31 */
136 #if defined(STM32F030x8) || defined(STM32F051x8) || defined(STM32F058xx)
137 #define OB_WRP_PAGES32TO35             ((uint32_t)0x00000100) /* Write protection of page 32 to 35 */
138 #define OB_WRP_PAGES36TO39             ((uint32_t)0x00000200) /* Write protection of page 36 to 39 */
139 #define OB_WRP_PAGES40TO43             ((uint32_t)0x00000400) /* Write protection of page 40 to 43 */
140 #define OB_WRP_PAGES44TO47             ((uint32_t)0x00000800) /* Write protection of page 44 to 47 */
141 #define OB_WRP_PAGES48TO51             ((uint32_t)0x00001000) /* Write protection of page 48 to 51 */
142 #define OB_WRP_PAGES52TO57             ((uint32_t)0x00002000) /* Write protection of page 52 to 57 */
143 #define OB_WRP_PAGES56TO59             ((uint32_t)0x00004000) /* Write protection of page 56 to 59 */
144 #define OB_WRP_PAGES60TO63             ((uint32_t)0x00008000) /* Write protection of page 60 to 63 */
145 #endif /* STM32F030x8 || STM32F051x8 || STM32F058xx */
146
147 #define OB_WRP_PAGES0TO31MASK          ((uint32_t)0x000000FF)
148 #if defined(STM32F030x8) || defined(STM32F051x8) || defined(STM32F058xx)
149 #define OB_WRP_PAGES32TO63MASK         ((uint32_t)0x0000FF00)
150 #endif /* STM32F030x8 || STM32F051x8 || STM32F058xx */
151
152 #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F038xx)|| defined(STM32F070x6)
153 #define OB_WRP_ALLPAGES                ((uint32_t)0x000000FF) /*!< Write protection of all pages */
154 #endif /* STM32F030x6 || STM32F031x6 || STM32F042x6 || STM32F048xx || STM32F038xx || STM32F070x6 */
155
156 #if defined(STM32F030x8) || defined(STM32F051x8) || defined(STM32F058xx)
157 #define OB_WRP_ALLPAGES                ((uint32_t)0x0000FFFF) /*!< Write protection of all pages */
158 #endif /* STM32F030x8 || STM32F051x8 || STM32F058xx */
159 #endif /* STM32F030x6 || STM32F030x8 || STM32F031x6 || STM32F051x8 || STM32F042x6 || STM32F048xx || STM32F038xx || STM32F058xx || STM32F070x6 */
160       
161 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
162     defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
163 #define OB_WRP_PAGES0TO1               ((uint32_t)0x00000001) /* Write protection of page 0 to 1 */
164 #define OB_WRP_PAGES2TO3               ((uint32_t)0x00000002) /* Write protection of page 2 to 3 */
165 #define OB_WRP_PAGES4TO5               ((uint32_t)0x00000004) /* Write protection of page 4 to 5 */
166 #define OB_WRP_PAGES6TO7               ((uint32_t)0x00000008) /* Write protection of page 6 to 7 */
167 #define OB_WRP_PAGES8TO9               ((uint32_t)0x00000010) /* Write protection of page 8 to 9 */
168 #define OB_WRP_PAGES10TO11             ((uint32_t)0x00000020) /* Write protection of page 10 to 11 */
169 #define OB_WRP_PAGES12TO13             ((uint32_t)0x00000040) /* Write protection of page 12 to 13 */
170 #define OB_WRP_PAGES14TO15             ((uint32_t)0x00000080) /* Write protection of page 14 to 15 */
171 #define OB_WRP_PAGES16TO17             ((uint32_t)0x00000100) /* Write protection of page 16 to 17 */
172 #define OB_WRP_PAGES18TO19             ((uint32_t)0x00000200) /* Write protection of page 18 to 19 */
173 #define OB_WRP_PAGES20TO21             ((uint32_t)0x00000400) /* Write protection of page 20 to 21 */
174 #define OB_WRP_PAGES22TO23             ((uint32_t)0x00000800) /* Write protection of page 22 to 23 */
175 #define OB_WRP_PAGES24TO25             ((uint32_t)0x00001000) /* Write protection of page 24 to 25 */
176 #define OB_WRP_PAGES26TO27             ((uint32_t)0x00002000) /* Write protection of page 26 to 27 */
177 #define OB_WRP_PAGES28TO29             ((uint32_t)0x00004000) /* Write protection of page 28 to 29 */
178 #define OB_WRP_PAGES30TO31             ((uint32_t)0x00008000) /* Write protection of page 30 to 31 */
179 #define OB_WRP_PAGES32TO33             ((uint32_t)0x00010000) /* Write protection of page 32 to 33 */
180 #define OB_WRP_PAGES34TO35             ((uint32_t)0x00020000) /* Write protection of page 34 to 35 */
181 #define OB_WRP_PAGES36TO37             ((uint32_t)0x00040000) /* Write protection of page 36 to 37 */
182 #define OB_WRP_PAGES38TO39             ((uint32_t)0x00080000) /* Write protection of page 38 to 39 */
183 #define OB_WRP_PAGES40TO41             ((uint32_t)0x00100000) /* Write protection of page 40 to 41 */
184 #define OB_WRP_PAGES42TO43             ((uint32_t)0x00200000) /* Write protection of page 42 to 43 */
185 #define OB_WRP_PAGES44TO45             ((uint32_t)0x00400000) /* Write protection of page 44 to 45 */
186 #define OB_WRP_PAGES46TO47             ((uint32_t)0x00800000) /* Write protection of page 46 to 47 */
187 #define OB_WRP_PAGES48TO49             ((uint32_t)0x01000000) /* Write protection of page 48 to 49 */
188 #define OB_WRP_PAGES50TO51             ((uint32_t)0x02000000) /* Write protection of page 50 to 51 */
189 #define OB_WRP_PAGES52TO53             ((uint32_t)0x04000000) /* Write protection of page 52 to 53 */
190 #define OB_WRP_PAGES54TO55             ((uint32_t)0x08000000) /* Write protection of page 54 to 55 */
191 #define OB_WRP_PAGES56TO57             ((uint32_t)0x10000000) /* Write protection of page 56 to 57 */
192 #define OB_WRP_PAGES58TO59             ((uint32_t)0x20000000) /* Write protection of page 58 to 59 */
193 #define OB_WRP_PAGES60TO61             ((uint32_t)0x40000000) /* Write protection of page 60 to 61 */
194 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
195 #define OB_WRP_PAGES62TO63             ((uint32_t)0x80000000) /* Write protection of page 62 to 63 */
196 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB */
197 #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
198 #define OB_WRP_PAGES62TO127            ((uint32_t)0x80000000) /* Write protection of page 62 to 127 */
199 #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
200
201 #define OB_WRP_PAGES0TO15MASK          ((uint32_t)0x000000FF)
202 #define OB_WRP_PAGES16TO31MASK         ((uint32_t)0x0000FF00)
203 #define OB_WRP_PAGES32TO47MASK         ((uint32_t)0x00FF0000)
204 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
205 #define OB_WRP_PAGES48TO63MASK         ((uint32_t)0xFF000000)
206 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB */
207 #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
208 #define OB_WRP_PAGES48TO127MASK        ((uint32_t)0xFF000000)
209 #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
210
211 #define OB_WRP_ALLPAGES                ((uint32_t)0xFFFFFFFF) /*!< Write protection of all pages */
212 #endif /* STM32F071xB || STM32F072xB || STM32F078xx  || STM32F091xC || STM32F098xx || STM32F030xC || STM32F070xB */
213
214 #define IS_OB_WRP(PAGE) (((PAGE) != 0x0000000))
215 /**
216   * @}
217   */
218
219 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)|| defined(STM32F070x6)
220 /** @defgroup FLASHEx_OB_BOOT_SEL FLASHEx OB BOOT SEL
221   * @{
222   */
223 #define OB_BOOT_SEL_RESET          ((uint8_t)0x00) /*!< BOOT_SEL Reset */
224 #define OB_BOOT_SEL_SET            ((uint8_t)0x80) /*!< BOOT_SEL Set */
225 #define IS_OB_BOOT_SEL(BOOT_SEL)   (((BOOT_SEL) == OB_BOOT_SEL_RESET) || ((BOOT_SEL) == OB_BOOT_SEL_SET))
226 /**
227   * @}
228   */  
229
230 /** @defgroup FLASHEx_OB_BOOT0 FLASHEx OB BOOT0
231   * @{
232   */
233 #define OB_BOOT0_RESET             ((uint8_t)0x00) /*!< BOOT0 Reset */
234 #define OB_BOOT0_SET               ((uint8_t)0x08) /*!< BOOT0 Set */
235 #define IS_OB_BOOT0(BOOT0)         (((BOOT0) == OB_BOOT0_RESET) || ((BOOT0) == OB_BOOT0_SET))
236 /**
237   * @}
238   */  
239 #endif /* STM32F042x6 || STM32F048xx || STM32F091xC || STM32F098xx || STM32F030xC || STM32F070x6 */
240
241 /**
242   * @}
243   */ 
244   
245 /* Exported macro ------------------------------------------------------------*/
246
247 /* Exported functions --------------------------------------------------------*/
248 /** @addtogroup FLASHEx_Exported_Functions FLASHEx Exported Functions
249   * @{
250   */
251   
252 /** @addtogroup FLASHEx_Exported_Functions_Group2 Extended I/O operation functions
253   * @brief    Extended I/O operation functions
254   * @{
255   */   
256 /* IO operation functions *****************************************************/
257 HAL_StatusTypeDef  HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError);
258 HAL_StatusTypeDef  HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
259
260 /**
261   * @}
262   */ 
263
264 /** @addtogroup FLASHEx_Exported_Functions_Group3 Extended Peripheral Control functions
265   * @brief    Extended Peripheral Control functions
266   * @{
267   */   
268 /* Peripheral Control functions ***********************************************/
269 HAL_StatusTypeDef  HAL_FLASHEx_OBErase(void);
270 HAL_StatusTypeDef  HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
271 void               HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
272
273 /**
274   * @}
275   */
276
277 /**
278   * @}
279   */
280   
281 /**
282   * @}
283   */
284
285 /**
286   * @}
287   */
288     
289 #ifdef __cplusplus
290 }
291 #endif
292
293 #endif /* __STM32F0xx_HAL_FLASH_EX_H */
294
295 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
296