]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F1/stm32f1xx_hal_flash.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F1 / stm32f1xx_hal_flash.h
1 /**
2 ******************************************************************************
3 * @file stm32f1xx_hal_flash.h
4 * @author MCD Application Team
5 * @version V1.0.0
6 * @date 15-December-2014
7 * @brief Header file of Flash HAL 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 __STM32F1xx_HAL_FLASH_H
40 #define __STM32F1xx_HAL_FLASH_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f1xx_hal_def.h"
48
49 /** @addtogroup STM32F1xx_HAL_Driver
50 * @{
51 */
52
53 /** @addtogroup FLASH
54 * @{
55 */
56
57 /** @addtogroup FLASH_Private_Constants
58 * @{
59 */
60 #define FLASH_TIMEOUT_VALUE ((uint32_t)50000)/* 50 s */
61 /**
62 * @}
63 */
64
65 /** @addtogroup FLASH_Private_Macros
66 * @{
67 */
68
69 #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \
70 ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \
71 ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD))
72
73 /**
74 * @}
75 */
76
77 /* Exported types ------------------------------------------------------------*/
78 /** @defgroup FLASH_Exported_Types FLASH Exported Types
79 * @{
80 */
81
82
83 /**
84 * @brief FLASH Procedure structure definition
85 */
86 typedef enum
87 {
88 FLASH_PROC_NONE = 0,
89 FLASH_PROC_PAGEERASE = 1,
90 FLASH_PROC_MASSERASE = 2,
91 FLASH_PROC_PROGRAMHALFWORD = 3,
92 FLASH_PROC_PROGRAMWORD = 4,
93 FLASH_PROC_PROGRAMDOUBLEWORD = 5
94 } FLASH_ProcedureTypeDef;
95
96 /**
97 * @brief FLASH handle Structure definition
98 */
99 typedef struct
100 {
101 __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /* Internal variable to indicate which procedure is ongoing or not in IT context */
102
103 __IO uint32_t DataRemaining; /* Internal variable to save the remaining pages to erase or half-word to program in IT context */
104
105 __IO uint32_t Address; /* Internal variable to save address selected for program or erase */
106
107 __IO uint64_t Data; /* Internal variable to save data to be programmed */
108
109 HAL_LockTypeDef Lock; /* FLASH locking object */
110
111 __IO uint32_t ErrorCode; /* FLASH error code */
112
113 } FLASH_ProcessTypeDef;
114
115 /**
116 * @}
117 */
118
119 /* Exported constants --------------------------------------------------------*/
120 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
121 * @{
122 */
123
124 /** @defgroup FLASH_Error_Codes FLASH Error Codes
125 * @{
126 */
127
128 #define HAL_FLASH_ERROR_NONE ((uint32_t)0x00)
129 #define HAL_FLASH_ERROR_PROG ((uint32_t)0x01)
130 #define HAL_FLASH_ERROR_WRP ((uint32_t)0x02)
131 #define HAL_FLASH_ERROR_OPTV ((uint32_t)0x04)
132
133 /**
134 * @}
135 */
136
137
138 /** @defgroup FLASH_Type_Program Type Program
139 * @{
140 */
141 #define FLASH_TYPEPROGRAM_HALFWORD ((uint32_t)0x01) /*!<Program a half-word (16-bit) at a specified address.*/
142 #define FLASH_TYPEPROGRAM_WORD ((uint32_t)0x02) /*!<Program a word (32-bit) at a specified address.*/
143 #define FLASH_TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x03) /*!<Program a double word (64-bit) at a specified address*/
144
145 /**
146 * @}
147 */
148
149 /**
150 * @}
151 */
152
153 /* Exported macro ------------------------------------------------------------*/
154
155 /** @defgroup FLASH_Exported_Macros FLASH Exported Macros
156 * @brief macros to control FLASH features
157 * @{
158 */
159
160 /**
161 * @brief Enable the FLASH half cycle access.
162 * @note halfcycle access can only be used with a low-frequency clock of less than
163 8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
164 * @retval None
165 */
166 #define __HAL_FLASH_HALF_CYCLE_ACCESS_ENABLE() (FLASH->ACR |= FLASH_ACR_HLFCYA)
167
168 /**
169 * @brief Disable the FLASH half cycle access.
170 * @note halfcycle access can only be used with a low-frequency clock of less than
171 8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
172 * @retval None
173 */
174 #define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA))
175
176 /**
177 * @}
178 */
179
180 /* Include FLASH HAL Extended module */
181 #include "stm32f1xx_hal_flash_ex.h"
182
183 /* Exported functions --------------------------------------------------------*/
184 /** @addtogroup FLASH_Exported_Functions
185 * @{
186 */
187
188 /** @addtogroup FLASH_Exported_Functions_Group1
189 * @{
190 */
191 /* IO operation functions *****************************************************/
192 HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
193 HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
194
195 /* FLASH IRQ handler method */
196 void HAL_FLASH_IRQHandler(void);
197 /* Callbacks in non blocking modes */
198 void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
199 void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
200
201 /**
202 * @}
203 */
204
205 /** @addtogroup FLASH_Exported_Functions_Group2
206 * @{
207 */
208 /* Peripheral Control functions ***********************************************/
209 HAL_StatusTypeDef HAL_FLASH_Unlock(void);
210 HAL_StatusTypeDef HAL_FLASH_Lock(void);
211 HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
212 HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
213 HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
214
215 /**
216 * @}
217 */
218
219 /** @addtogroup FLASH_Exported_Functions_Group3
220 * @{
221 */
222 /* Peripheral State and Error functions ***************************************/
223 uint32_t HAL_FLASH_GetError(void);
224
225 /**
226 * @}
227 */
228
229 /**
230 * @}
231 */
232
233 /* Private function -------------------------------------------------*/
234 /** @addtogroup FLASH_Private_Functions
235 * @{
236 */
237 void FLASH_PageErase(uint32_t PageAddress);
238 HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);
239 void FLASH_SetErrorCode(void);
240 void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data);
241
242 /**
243 * @}
244 */
245
246 /**
247 * @}
248 */
249
250 /**
251 * @}
252 */
253
254 #ifdef __cplusplus
255 }
256 #endif
257
258 #endif /* __STM32F1xx_HAL_FLASH_H */
259
260 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
261
Imprint / Impressum