Subversion Repositories EDIS_Ignition

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 18
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32f1xx_hal_flash.h
3
  * @file    stm32f1xx_hal_flash.h
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   Header file of Flash HAL module.
5
  * @brief   Header file of Flash HAL module.
6
  ******************************************************************************
6
  ******************************************************************************
7
  * @attention
7
  * @attention
8
  *
8
  *
9
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
9
  * Copyright (c) 2016 STMicroelectronics.
10
  * All rights reserved.</center></h2>
10
  * All rights reserved.
11
  *
11
  *
12
  * This software component is licensed by ST under BSD 3-Clause license,
12
  * This software is licensed under terms that can be found in the LICENSE file in
13
  * the "License"; You may not use this file except in compliance with the
13
  * the root directory of this software component.
14
  * License. You may obtain a copy of the License at:
14
  * If no LICENSE file comes with this software, it is provided AS-IS.
15
  *                        opensource.org/licenses/BSD-3-Clause
15
  ******************************************************************************
16
  *
16
  */
17
  ******************************************************************************
17
 
18
  */
18
/* Define to prevent recursive inclusion -------------------------------------*/
19
 
19
#ifndef __STM32F1xx_HAL_FLASH_H
20
/* Define to prevent recursive inclusion -------------------------------------*/
20
#define __STM32F1xx_HAL_FLASH_H
21
#ifndef __STM32F1xx_HAL_FLASH_H
21
 
22
#define __STM32F1xx_HAL_FLASH_H
22
#ifdef __cplusplus
23
 
23
 extern "C" {
24
#ifdef __cplusplus
24
#endif
25
 extern "C" {
25
 
26
#endif
26
/* Includes ------------------------------------------------------------------*/
27
 
27
#include "stm32f1xx_hal_def.h"
28
/* Includes ------------------------------------------------------------------*/
28
   
29
#include "stm32f1xx_hal_def.h"
29
/** @addtogroup STM32F1xx_HAL_Driver
30
   
30
  * @{
31
/** @addtogroup STM32F1xx_HAL_Driver
31
  */
32
  * @{
32
 
33
  */
33
/** @addtogroup FLASH
34
 
34
  * @{
35
/** @addtogroup FLASH
35
  */
36
  * @{
36
 
37
  */
37
/** @addtogroup FLASH_Private_Constants
38
 
38
  * @{
39
/** @addtogroup FLASH_Private_Constants
39
  */
40
  * @{
40
#define FLASH_TIMEOUT_VALUE              50000U /* 50 s */
41
  */
41
/**
42
#define FLASH_TIMEOUT_VALUE              50000U /* 50 s */
42
  * @}
43
/**
43
  */
44
  * @}
44
 
45
  */
45
/** @addtogroup FLASH_Private_Macros
46
 
46
  * @{
47
/** @addtogroup FLASH_Private_Macros
47
  */
48
  * @{
48
 
49
  */
49
#define IS_FLASH_TYPEPROGRAM(VALUE)  (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \
50
 
50
                                      ((VALUE) == FLASH_TYPEPROGRAM_WORD)     || \
51
#define IS_FLASH_TYPEPROGRAM(VALUE)  (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \
51
                                      ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD))  
52
                                      ((VALUE) == FLASH_TYPEPROGRAM_WORD)     || \
52
 
53
                                      ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD))  
53
#if   defined(FLASH_ACR_LATENCY)
54
 
54
#define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \
55
#if   defined(FLASH_ACR_LATENCY)
55
                                       ((__LATENCY__) == FLASH_LATENCY_1) || \
56
#define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \
56
                                       ((__LATENCY__) == FLASH_LATENCY_2))
57
                                       ((__LATENCY__) == FLASH_LATENCY_1) || \
57
 
58
                                       ((__LATENCY__) == FLASH_LATENCY_2))
58
#else
59
 
59
#define IS_FLASH_LATENCY(__LATENCY__)   ((__LATENCY__) == FLASH_LATENCY_0)
60
#else
60
#endif /* FLASH_ACR_LATENCY */
61
#define IS_FLASH_LATENCY(__LATENCY__)   ((__LATENCY__) == FLASH_LATENCY_0)
61
/**
62
#endif /* FLASH_ACR_LATENCY */
62
  * @}
63
/**
63
  */  
64
  * @}
64
 
65
  */  
65
/* Exported types ------------------------------------------------------------*/
66
 
66
/** @defgroup FLASH_Exported_Types FLASH Exported Types
67
/* Exported types ------------------------------------------------------------*/
67
  * @{
68
/** @defgroup FLASH_Exported_Types FLASH Exported Types
68
  */  
69
  * @{
69
 
70
  */  
70
/**
71
 
71
  * @brief  FLASH Procedure structure definition
72
/**
72
  */
73
  * @brief  FLASH Procedure structure definition
73
typedef enum
74
  */
74
{
75
typedef enum
75
  FLASH_PROC_NONE              = 0U,
76
{
76
  FLASH_PROC_PAGEERASE         = 1U,
77
  FLASH_PROC_NONE              = 0U,
77
  FLASH_PROC_MASSERASE         = 2U,
78
  FLASH_PROC_PAGEERASE         = 1U,
78
  FLASH_PROC_PROGRAMHALFWORD   = 3U,
79
  FLASH_PROC_MASSERASE         = 2U,
79
  FLASH_PROC_PROGRAMWORD       = 4U,
80
  FLASH_PROC_PROGRAMHALFWORD   = 3U,
80
  FLASH_PROC_PROGRAMDOUBLEWORD = 5U
81
  FLASH_PROC_PROGRAMWORD       = 4U,
81
} FLASH_ProcedureTypeDef;
82
  FLASH_PROC_PROGRAMDOUBLEWORD = 5U
82
 
83
} FLASH_ProcedureTypeDef;
83
/**
84
 
84
  * @brief  FLASH handle Structure definition  
85
/**
85
  */
86
  * @brief  FLASH handle Structure definition  
86
typedef struct
87
  */
87
{
88
typedef struct
88
  __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */
89
{
89
 
90
  __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */
90
  __IO uint32_t               DataRemaining;    /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */
91
 
91
 
92
  __IO uint32_t               DataRemaining;    /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */
92
  __IO uint32_t               Address;          /*!< Internal variable to save address selected for program or erase */
93
 
93
 
94
  __IO uint32_t               Address;          /*!< Internal variable to save address selected for program or erase */
94
  __IO uint64_t               Data;             /*!< Internal variable to save data to be programmed */
95
 
95
 
96
  __IO uint64_t               Data;             /*!< Internal variable to save data to be programmed */
96
  HAL_LockTypeDef             Lock;             /*!< FLASH locking object                */
97
 
97
 
98
  HAL_LockTypeDef             Lock;             /*!< FLASH locking object                */
98
  __IO uint32_t               ErrorCode;        /*!< FLASH error code                    
99
 
99
                                                     This parameter can be a value of @ref FLASH_Error_Codes  */
100
  __IO uint32_t               ErrorCode;        /*!< FLASH error code                    
100
} FLASH_ProcessTypeDef;
101
                                                     This parameter can be a value of @ref FLASH_Error_Codes  */
101
 
102
} FLASH_ProcessTypeDef;
102
/**
103
 
103
  * @}
104
/**
104
  */
105
  * @}
105
 
106
  */
106
/* Exported constants --------------------------------------------------------*/
107
 
107
/** @defgroup FLASH_Exported_Constants FLASH Exported Constants
108
/* Exported constants --------------------------------------------------------*/
108
  * @{
109
/** @defgroup FLASH_Exported_Constants FLASH Exported Constants
109
  */  
110
  * @{
110
 
111
  */  
111
/** @defgroup FLASH_Error_Codes FLASH Error Codes
112
 
112
  * @{
113
/** @defgroup FLASH_Error_Codes FLASH Error Codes
113
  */
114
  * @{
114
 
115
  */
115
#define HAL_FLASH_ERROR_NONE      0x00U  /*!< No error */
116
 
116
#define HAL_FLASH_ERROR_PROG      0x01U  /*!< Programming error */
117
#define HAL_FLASH_ERROR_NONE      0x00U  /*!< No error */
117
#define HAL_FLASH_ERROR_WRP       0x02U  /*!< Write protection error */
118
#define HAL_FLASH_ERROR_PROG      0x01U  /*!< Programming error */
118
#define HAL_FLASH_ERROR_OPTV      0x04U  /*!< Option validity error */
119
#define HAL_FLASH_ERROR_WRP       0x02U  /*!< Write protection error */
119
 
120
#define HAL_FLASH_ERROR_OPTV      0x04U  /*!< Option validity error */
120
/**
121
 
121
  * @}
122
/**
122
  */
123
  * @}
123
 
124
  */
124
/** @defgroup FLASH_Type_Program FLASH Type Program
125
 
125
  * @{
126
/** @defgroup FLASH_Type_Program FLASH Type Program
126
  */
127
  * @{
127
#define FLASH_TYPEPROGRAM_HALFWORD             0x01U  /*!<Program a half-word (16-bit) at a specified address.*/
128
  */
128
#define FLASH_TYPEPROGRAM_WORD                 0x02U  /*!<Program a word (32-bit) at a specified address.*/
129
#define FLASH_TYPEPROGRAM_HALFWORD             0x01U  /*!<Program a half-word (16-bit) at a specified address.*/
129
#define FLASH_TYPEPROGRAM_DOUBLEWORD           0x03U  /*!<Program a double word (64-bit) at a specified address*/
130
#define FLASH_TYPEPROGRAM_WORD                 0x02U  /*!<Program a word (32-bit) at a specified address.*/
130
 
131
#define FLASH_TYPEPROGRAM_DOUBLEWORD           0x03U  /*!<Program a double word (64-bit) at a specified address*/
131
/**
132
 
132
  * @}
133
/**
133
  */
134
  * @}
134
 
135
  */
135
#if   defined(FLASH_ACR_LATENCY)
136
 
136
/** @defgroup FLASH_Latency FLASH Latency
137
#if   defined(FLASH_ACR_LATENCY)
137
  * @{
138
/** @defgroup FLASH_Latency FLASH Latency
138
  */
139
  * @{
139
#define FLASH_LATENCY_0            0x00000000U               /*!< FLASH Zero Latency cycle */
140
  */
140
#define FLASH_LATENCY_1            FLASH_ACR_LATENCY_0       /*!< FLASH One Latency cycle */
141
#define FLASH_LATENCY_0            0x00000000U               /*!< FLASH Zero Latency cycle */
141
#define FLASH_LATENCY_2            FLASH_ACR_LATENCY_1       /*!< FLASH Two Latency cycles */
142
#define FLASH_LATENCY_1            FLASH_ACR_LATENCY_0       /*!< FLASH One Latency cycle */
142
 
143
#define FLASH_LATENCY_2            FLASH_ACR_LATENCY_1       /*!< FLASH Two Latency cycles */
143
/**
144
 
144
  * @}
145
/**
145
  */
146
  * @}
146
 
147
  */
147
#else
148
 
148
/** @defgroup FLASH_Latency FLASH Latency
149
#else
149
  * @{
150
/** @defgroup FLASH_Latency FLASH Latency
150
  */
151
  * @{
151
#define FLASH_LATENCY_0            0x00000000U    /*!< FLASH Zero Latency cycle */
152
  */
152
 
153
#define FLASH_LATENCY_0            0x00000000U    /*!< FLASH Zero Latency cycle */
153
/**
154
 
154
  * @}
155
/**
155
  */
156
  * @}
156
 
157
  */
157
#endif /* FLASH_ACR_LATENCY */
158
 
158
/**
159
#endif /* FLASH_ACR_LATENCY */
159
  * @}
160
/**
160
  */  
161
  * @}
161
 
162
  */  
162
/* Exported macro ------------------------------------------------------------*/
163
 
163
 
164
/* Exported macro ------------------------------------------------------------*/
164
/** @defgroup FLASH_Exported_Macros FLASH Exported Macros
165
 
165
 *  @brief macros to control FLASH features
166
/** @defgroup FLASH_Exported_Macros FLASH Exported Macros
166
 *  @{
167
 *  @brief macros to control FLASH features
167
 */
168
 *  @{
168
 
169
 */
169
/** @defgroup FLASH_Half_Cycle FLASH Half Cycle
170
 
170
 *  @brief macros to handle FLASH half cycle
171
/** @defgroup FLASH_Half_Cycle FLASH Half Cycle
171
 * @{
172
 *  @brief macros to handle FLASH half cycle
172
 */
173
 * @{
173
 
174
 */
174
/**
175
 
175
  * @brief  Enable the FLASH half cycle access.
176
/**
176
  * @note   half cycle access can only be used with a low-frequency clock of less than
177
  * @brief  Enable the FLASH half cycle access.
177
            8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
178
  * @note   half cycle access can only be used with a low-frequency clock of less than
178
  * @retval None
179
            8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
179
  */
180
  * @retval None
180
#define __HAL_FLASH_HALF_CYCLE_ACCESS_ENABLE()  (FLASH->ACR |= FLASH_ACR_HLFCYA)
181
  */
181
 
182
#define __HAL_FLASH_HALF_CYCLE_ACCESS_ENABLE()  (FLASH->ACR |= FLASH_ACR_HLFCYA)
182
/**
183
 
183
  * @brief  Disable the FLASH half cycle access.
184
/**
184
  * @note   half cycle access can only be used with a low-frequency clock of less than
185
  * @brief  Disable the FLASH half cycle access.
185
            8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
186
  * @note   half cycle access can only be used with a low-frequency clock of less than
186
  * @retval None
187
            8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
187
  */
188
  * @retval None
188
#define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA))
189
  */
189
 
190
#define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA))
190
/**
191
 
191
  * @}
192
/**
192
  */
193
  * @}
193
 
194
  */
194
#if defined(FLASH_ACR_LATENCY)
195
 
195
/** @defgroup FLASH_EM_Latency FLASH Latency
196
#if defined(FLASH_ACR_LATENCY)
196
 *  @brief macros to handle FLASH Latency
197
/** @defgroup FLASH_EM_Latency FLASH Latency
197
 * @{
198
 *  @brief macros to handle FLASH Latency
198
 */
199
 * @{
199
 
200
 */
200
/**
201
 
201
  * @brief  Set the FLASH Latency.
202
/**
202
  * @param  __LATENCY__ FLASH Latency                  
203
  * @brief  Set the FLASH Latency.
203
  *         The value of this parameter depend on device used within the same series
204
  * @param  __LATENCY__ FLASH Latency                  
204
  * @retval None
205
  *         The value of this parameter depend on device used within the same series
205
  */
206
  * @retval None
206
#define __HAL_FLASH_SET_LATENCY(__LATENCY__)    (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__))
207
  */
207
 
208
#define __HAL_FLASH_SET_LATENCY(__LATENCY__)    (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__))
208
 
209
 
209
/**
210
 
210
  * @brief  Get the FLASH Latency.
211
/**
211
  * @retval FLASH Latency                  
212
  * @brief  Get the FLASH Latency.
212
  *         The value of this parameter depend on device used within the same series
213
  * @retval FLASH Latency                  
213
  */
214
  *         The value of this parameter depend on device used within the same series
214
#define __HAL_FLASH_GET_LATENCY()     (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))
215
  */
215
 
216
#define __HAL_FLASH_GET_LATENCY()     (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))
216
/**
217
 
217
  * @}
218
/**
218
  */
219
  * @}
219
 
220
  */
220
#endif /* FLASH_ACR_LATENCY */
221
 
221
/** @defgroup FLASH_Prefetch FLASH Prefetch
222
#endif /* FLASH_ACR_LATENCY */
222
 *  @brief macros to handle FLASH Prefetch buffer
223
/** @defgroup FLASH_Prefetch FLASH Prefetch
223
 * @{
224
 *  @brief macros to handle FLASH Prefetch buffer
224
 */  
225
 * @{
225
/**
226
 */  
226
  * @brief  Enable the FLASH prefetch buffer.
227
/**
227
  * @retval None
228
  * @brief  Enable the FLASH prefetch buffer.
228
  */
229
  * @retval None
229
#define __HAL_FLASH_PREFETCH_BUFFER_ENABLE()    (FLASH->ACR |= FLASH_ACR_PRFTBE)
230
  */
230
 
231
#define __HAL_FLASH_PREFETCH_BUFFER_ENABLE()    (FLASH->ACR |= FLASH_ACR_PRFTBE)
231
/**
232
 
232
  * @brief  Disable the FLASH prefetch buffer.
233
/**
233
  * @retval None
234
  * @brief  Disable the FLASH prefetch buffer.
234
  */
235
  * @retval None
235
#define __HAL_FLASH_PREFETCH_BUFFER_DISABLE()   (FLASH->ACR &= (~FLASH_ACR_PRFTBE))
236
  */
236
 
237
#define __HAL_FLASH_PREFETCH_BUFFER_DISABLE()   (FLASH->ACR &= (~FLASH_ACR_PRFTBE))
237
/**
238
 
238
  * @}
239
/**
239
  */
240
  * @}
240
 
241
  */
241
/**
242
 
242
  * @}
243
/**
243
  */
244
  * @}
244
 
245
  */
245
/* Include FLASH HAL Extended module */
246
 
246
#include "stm32f1xx_hal_flash_ex.h"  
247
/* Include FLASH HAL Extended module */
247
 
248
#include "stm32f1xx_hal_flash_ex.h"  
248
/* Exported functions --------------------------------------------------------*/
249
 
249
/** @addtogroup FLASH_Exported_Functions
250
/* Exported functions --------------------------------------------------------*/
250
  * @{
251
/** @addtogroup FLASH_Exported_Functions
251
  */
252
  * @{
252
 
253
  */
253
/** @addtogroup FLASH_Exported_Functions_Group1
254
 
254
  * @{
255
/** @addtogroup FLASH_Exported_Functions_Group1
255
  */
256
  * @{
256
/* IO operation functions *****************************************************/
257
  */
257
HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
258
/* IO operation functions *****************************************************/
258
HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
259
HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
259
 
260
HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
260
/* FLASH IRQ handler function */
261
 
261
void       HAL_FLASH_IRQHandler(void);
262
/* FLASH IRQ handler function */
262
/* Callbacks in non blocking modes */
263
void       HAL_FLASH_IRQHandler(void);
263
void       HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
264
/* Callbacks in non blocking modes */
264
void       HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
265
void       HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
265
 
266
void       HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
266
/**
267
 
267
  * @}
268
/**
268
  */
269
  * @}
269
 
270
  */
270
/** @addtogroup FLASH_Exported_Functions_Group2
271
 
271
  * @{
272
/** @addtogroup FLASH_Exported_Functions_Group2
272
  */
273
  * @{
273
/* Peripheral Control functions ***********************************************/
274
  */
274
HAL_StatusTypeDef HAL_FLASH_Unlock(void);
275
/* Peripheral Control functions ***********************************************/
275
HAL_StatusTypeDef HAL_FLASH_Lock(void);
276
HAL_StatusTypeDef HAL_FLASH_Unlock(void);
276
HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
277
HAL_StatusTypeDef HAL_FLASH_Lock(void);
277
HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
278
HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
278
void HAL_FLASH_OB_Launch(void);
279
HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
279
 
280
void HAL_FLASH_OB_Launch(void);
280
/**
281
 
281
  * @}
282
/**
282
  */
283
  * @}
283
 
284
  */
284
/** @addtogroup FLASH_Exported_Functions_Group3
285
 
285
  * @{
286
/** @addtogroup FLASH_Exported_Functions_Group3
286
  */
287
  * @{
287
/* Peripheral State and Error functions ***************************************/
288
  */
288
uint32_t HAL_FLASH_GetError(void);
289
/* Peripheral State and Error functions ***************************************/
289
 
290
uint32_t HAL_FLASH_GetError(void);
290
/**
291
 
291
  * @}
292
/**
292
  */
293
  * @}
293
 
294
  */
294
/**
295
 
295
  * @}
296
/**
296
  */
297
  * @}
297
 
298
  */
298
/* Private function -------------------------------------------------*/
299
 
299
/** @addtogroup FLASH_Private_Functions
300
/* Private function -------------------------------------------------*/
300
 * @{
301
/** @addtogroup FLASH_Private_Functions
301
 */
302
 * @{
302
HAL_StatusTypeDef       FLASH_WaitForLastOperation(uint32_t Timeout);
303
 */
303
#if defined(FLASH_BANK2_END)
304
HAL_StatusTypeDef       FLASH_WaitForLastOperation(uint32_t Timeout);
304
HAL_StatusTypeDef       FLASH_WaitForLastOperationBank2(uint32_t Timeout);
305
#if defined(FLASH_BANK2_END)
305
#endif /* FLASH_BANK2_END */
306
HAL_StatusTypeDef       FLASH_WaitForLastOperationBank2(uint32_t Timeout);
306
 
307
#endif /* FLASH_BANK2_END */
307
/**
308
 
308
  * @}
309
/**
309
  */
310
  * @}
310
 
311
  */
311
/**
312
 
312
  * @}
313
/**
313
  */
314
  * @}
314
 
315
  */
315
/**
316
 
316
  * @}
317
/**
317
  */
318
  * @}
318
 
319
  */
319
#ifdef __cplusplus
320
 
320
}
321
#ifdef __cplusplus
321
#endif
322
}
322
 
323
#endif
323
#endif /* __STM32F1xx_HAL_FLASH_H */
324
 
324
 
325
#endif /* __STM32F1xx_HAL_FLASH_H */
325
 
326
 
-
 
327
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
 
328
 
-