RTEMS 6.1-rc5
Loading...
Searching...
No Matches
stm32h7xx_hal_flash.h
Go to the documentation of this file.
1
18/* Define to prevent recursive inclusion -------------------------------------*/
19#ifndef STM32H7xx_HAL_FLASH_H
20#define STM32H7xx_HAL_FLASH_H
21
22#ifdef __cplusplus
23 extern "C" {
24#endif
25
26/* Includes ------------------------------------------------------------------*/
27#include "stm32h7xx_hal_def.h"
28
37/* Exported types ------------------------------------------------------------*/
46typedef enum
47{
48 FLASH_PROC_NONE = 0U,
49 FLASH_PROC_SECTERASE_BANK1,
50 FLASH_PROC_MASSERASE_BANK1,
51 FLASH_PROC_PROGRAM_BANK1,
52 FLASH_PROC_SECTERASE_BANK2,
53 FLASH_PROC_MASSERASE_BANK2,
54 FLASH_PROC_PROGRAM_BANK2,
55 FLASH_PROC_ALLBANK_MASSERASE
57
58
62typedef struct
63{
70 __IO uint32_t Sector;
72 __IO uint32_t Address;
76 __IO uint32_t ErrorCode;
79
84/* Exported constants --------------------------------------------------------*/
95#define HAL_FLASH_ERROR_NONE 0x00000000U
97#define HAL_FLASH_ERROR_WRP FLASH_FLAG_WRPERR
98#define HAL_FLASH_ERROR_PGS FLASH_FLAG_PGSERR
99#define HAL_FLASH_ERROR_STRB FLASH_FLAG_STRBERR
100#define HAL_FLASH_ERROR_INC FLASH_FLAG_INCERR
101#if defined (FLASH_SR_OPERR)
102#define HAL_FLASH_ERROR_OPE FLASH_FLAG_OPERR
103#endif /* FLASH_SR_OPERR */
104#define HAL_FLASH_ERROR_RDP FLASH_FLAG_RDPERR
105#define HAL_FLASH_ERROR_RDS FLASH_FLAG_RDSERR
106#define HAL_FLASH_ERROR_SNECC FLASH_FLAG_SNECCERR
107#define HAL_FLASH_ERROR_DBECC FLASH_FLAG_DBECCERR
108#define HAL_FLASH_ERROR_CRCRD FLASH_FLAG_CRCRDERR
110#define HAL_FLASH_ERROR_WRP_BANK1 FLASH_FLAG_WRPERR_BANK1
111#define HAL_FLASH_ERROR_PGS_BANK1 FLASH_FLAG_PGSERR_BANK1
112#define HAL_FLASH_ERROR_STRB_BANK1 FLASH_FLAG_STRBERR_BANK1
113#define HAL_FLASH_ERROR_INC_BANK1 FLASH_FLAG_INCERR_BANK1
114#if defined (FLASH_SR_OPERR)
115#define HAL_FLASH_ERROR_OPE_BANK1 FLASH_FLAG_OPERR_BANK1
116#endif /* FLASH_SR_OPERR */
117#define HAL_FLASH_ERROR_RDP_BANK1 FLASH_FLAG_RDPERR_BANK1
118#define HAL_FLASH_ERROR_RDS_BANK1 FLASH_FLAG_RDSERR_BANK1
119#define HAL_FLASH_ERROR_SNECC_BANK1 FLASH_FLAG_SNECCERR_BANK1
120#define HAL_FLASH_ERROR_DBECC_BANK1 FLASH_FLAG_DBECCERR_BANK1
121#define HAL_FLASH_ERROR_CRCRD_BANK1 FLASH_FLAG_CRCRDERR_BANK1
123#define HAL_FLASH_ERROR_WRP_BANK2 FLASH_FLAG_WRPERR_BANK2
124#define HAL_FLASH_ERROR_PGS_BANK2 FLASH_FLAG_PGSERR_BANK2
125#define HAL_FLASH_ERROR_STRB_BANK2 FLASH_FLAG_STRBERR_BANK2
126#define HAL_FLASH_ERROR_INC_BANK2 FLASH_FLAG_INCERR_BANK2
127#if defined (FLASH_SR_OPERR)
128#define HAL_FLASH_ERROR_OPE_BANK2 FLASH_FLAG_OPERR_BANK2
129#endif /* FLASH_SR_OPERR */
130#define HAL_FLASH_ERROR_RDP_BANK2 FLASH_FLAG_RDPERR_BANK2
131#define HAL_FLASH_ERROR_RDS_BANK2 FLASH_FLAG_RDSERR_BANK2
132#define HAL_FLASH_ERROR_SNECC_BANK2 FLASH_FLAG_SNECCERR_BANK2
133#define HAL_FLASH_ERROR_DBECC_BANK2 FLASH_FLAG_DBECCERR_BANK2
134#define HAL_FLASH_ERROR_CRCRD_BANK2 FLASH_FLAG_CRCRDERR_BANK2
136#define HAL_FLASH_ERROR_OB_CHANGE FLASH_OPTSR_OPTCHANGEERR
145#define FLASH_TYPEPROGRAM_FLASHWORD 0x01U
146#if defined (FLASH_OPTCR_PG_OTP)
147#define FLASH_TYPEPROGRAM_OTPWORD 0x02U
148#endif /* FLASH_OPTCR_PG_OTP */
158#define FLASH_FLAG_BSY FLASH_SR_BSY
159#define FLASH_FLAG_WBNE FLASH_SR_WBNE
160#define FLASH_FLAG_QW FLASH_SR_QW
161#define FLASH_FLAG_CRC_BUSY FLASH_SR_CRC_BUSY
162#define FLASH_FLAG_EOP FLASH_SR_EOP
163#define FLASH_FLAG_WRPERR FLASH_SR_WRPERR
164#define FLASH_FLAG_PGSERR FLASH_SR_PGSERR
165#define FLASH_FLAG_STRBERR FLASH_SR_STRBERR
166#define FLASH_FLAG_INCERR FLASH_SR_INCERR
167#if defined (FLASH_SR_OPERR)
168#define FLASH_FLAG_OPERR FLASH_SR_OPERR
169#endif /* FLASH_SR_OPERR */
170#define FLASH_FLAG_RDPERR FLASH_SR_RDPERR
171#define FLASH_FLAG_RDSERR FLASH_SR_RDSERR
172#define FLASH_FLAG_SNECCERR FLASH_SR_SNECCERR
173#define FLASH_FLAG_DBECCERR FLASH_SR_DBECCERR
174#define FLASH_FLAG_CRCEND FLASH_SR_CRCEND
175#define FLASH_FLAG_CRCRDERR FLASH_SR_CRCRDERR
177#define FLASH_FLAG_BSY_BANK1 FLASH_SR_BSY
178#define FLASH_FLAG_WBNE_BANK1 FLASH_SR_WBNE
179#define FLASH_FLAG_QW_BANK1 FLASH_SR_QW
180#define FLASH_FLAG_CRC_BUSY_BANK1 FLASH_SR_CRC_BUSY
181#define FLASH_FLAG_EOP_BANK1 FLASH_SR_EOP
182#define FLASH_FLAG_WRPERR_BANK1 FLASH_SR_WRPERR
183#define FLASH_FLAG_PGSERR_BANK1 FLASH_SR_PGSERR
184#define FLASH_FLAG_STRBERR_BANK1 FLASH_SR_STRBERR
185#define FLASH_FLAG_INCERR_BANK1 FLASH_SR_INCERR
186#if defined (FLASH_SR_OPERR)
187#define FLASH_FLAG_OPERR_BANK1 FLASH_SR_OPERR
188#endif /* FLASH_SR_OPERR */
189#define FLASH_FLAG_RDPERR_BANK1 FLASH_SR_RDPERR
190#define FLASH_FLAG_RDSERR_BANK1 FLASH_SR_RDSERR
191#define FLASH_FLAG_SNECCERR_BANK1 FLASH_SR_SNECCERR
192#define FLASH_FLAG_DBECCERR_BANK1 FLASH_SR_DBECCERR
193#define FLASH_FLAG_CRCEND_BANK1 FLASH_SR_CRCEND
194#define FLASH_FLAG_CRCRDERR_BANK1 FLASH_SR_CRCRDERR
196#if defined (FLASH_SR_OPERR)
197#define FLASH_FLAG_ALL_ERRORS_BANK1 (FLASH_FLAG_WRPERR_BANK1 | FLASH_FLAG_PGSERR_BANK1 | \
198 FLASH_FLAG_STRBERR_BANK1 | FLASH_FLAG_INCERR_BANK1 | \
199 FLASH_FLAG_OPERR_BANK1 | FLASH_FLAG_RDPERR_BANK1 | \
200 FLASH_FLAG_RDSERR_BANK1 | FLASH_FLAG_SNECCERR_BANK1 | \
201 FLASH_FLAG_DBECCERR_BANK1 | FLASH_FLAG_CRCRDERR_BANK1)
202#else
203#define FLASH_FLAG_ALL_ERRORS_BANK1 (FLASH_FLAG_WRPERR_BANK1 | FLASH_FLAG_PGSERR_BANK1 | \
204 FLASH_FLAG_STRBERR_BANK1 | FLASH_FLAG_INCERR_BANK1 | \
205 FLASH_FLAG_RDPERR_BANK1 | FLASH_FLAG_RDSERR_BANK1 | \
206 FLASH_FLAG_SNECCERR_BANK1 | FLASH_FLAG_DBECCERR_BANK1 | \
207 FLASH_FLAG_CRCRDERR_BANK1)
208#endif /* FLASH_SR_OPERR */
209
210#define FLASH_FLAG_ALL_BANK1 (FLASH_FLAG_BSY_BANK1 | FLASH_FLAG_WBNE_BANK1 | \
211 FLASH_FLAG_QW_BANK1 | FLASH_FLAG_CRC_BUSY_BANK1 | \
212 FLASH_FLAG_EOP_BANK1 | FLASH_FLAG_CRCEND_BANK1 | \
213 FLASH_FLAG_ALL_ERRORS_BANK1)
215#define FLASH_FLAG_BSY_BANK2 (FLASH_SR_BSY | 0x80000000U)
216#define FLASH_FLAG_WBNE_BANK2 (FLASH_SR_WBNE | 0x80000000U)
217#define FLASH_FLAG_QW_BANK2 (FLASH_SR_QW | 0x80000000U)
218#define FLASH_FLAG_CRC_BUSY_BANK2 (FLASH_SR_CRC_BUSY | 0x80000000U)
219#define FLASH_FLAG_EOP_BANK2 (FLASH_SR_EOP | 0x80000000U)
220#define FLASH_FLAG_WRPERR_BANK2 (FLASH_SR_WRPERR | 0x80000000U)
221#define FLASH_FLAG_PGSERR_BANK2 (FLASH_SR_PGSERR | 0x80000000U)
222#define FLASH_FLAG_STRBERR_BANK2 (FLASH_SR_STRBERR | 0x80000000U)
223#define FLASH_FLAG_INCERR_BANK2 (FLASH_SR_INCERR | 0x80000000U)
224#if defined (FLASH_SR_OPERR)
225#define FLASH_FLAG_OPERR_BANK2 (FLASH_SR_OPERR | 0x80000000U)
226#endif /* FLASH_SR_OPERR */
227#define FLASH_FLAG_RDPERR_BANK2 (FLASH_SR_RDPERR | 0x80000000U)
228#define FLASH_FLAG_RDSERR_BANK2 (FLASH_SR_RDSERR | 0x80000000U)
229#define FLASH_FLAG_SNECCERR_BANK2 (FLASH_SR_SNECCERR | 0x80000000U)
230#define FLASH_FLAG_DBECCERR_BANK2 (FLASH_SR_DBECCERR | 0x80000000U)
231#define FLASH_FLAG_CRCEND_BANK2 (FLASH_SR_CRCEND | 0x80000000U)
232#define FLASH_FLAG_CRCRDERR_BANK2 (FLASH_SR_CRCRDERR | 0x80000000U)
234#if defined (FLASH_SR_OPERR)
235#define FLASH_FLAG_ALL_ERRORS_BANK2 (FLASH_FLAG_WRPERR_BANK2 | FLASH_FLAG_PGSERR_BANK2 | \
236 FLASH_FLAG_STRBERR_BANK2 | FLASH_FLAG_INCERR_BANK2 | \
237 FLASH_FLAG_OPERR_BANK2 | FLASH_FLAG_RDPERR_BANK2 | \
238 FLASH_FLAG_RDSERR_BANK2 | FLASH_FLAG_SNECCERR_BANK2 | \
239 FLASH_FLAG_DBECCERR_BANK2 | FLASH_FLAG_CRCRDERR_BANK2)
240#else
241#define FLASH_FLAG_ALL_ERRORS_BANK2 (FLASH_FLAG_WRPERR_BANK2 | FLASH_FLAG_PGSERR_BANK2 | \
242 FLASH_FLAG_STRBERR_BANK2 | FLASH_FLAG_INCERR_BANK2 | \
243 FLASH_FLAG_RDPERR_BANK2 | FLASH_FLAG_RDSERR_BANK2 | \
244 FLASH_FLAG_SNECCERR_BANK2 | FLASH_FLAG_DBECCERR_BANK2 | \
245 FLASH_FLAG_CRCRDERR_BANK2)
246#endif /* FLASH_SR_OPERR */
247
248#define FLASH_FLAG_ALL_BANK2 (FLASH_FLAG_BSY_BANK2 | FLASH_FLAG_WBNE_BANK2 | \
249 FLASH_FLAG_QW_BANK2 | FLASH_FLAG_CRC_BUSY_BANK2 | \
250 FLASH_FLAG_EOP_BANK2 | FLASH_FLAG_CRCEND_BANK2 | \
251 FLASH_FLAG_ALL_ERRORS_BANK2)
261#define FLASH_IT_EOP_BANK1 FLASH_CR_EOPIE
262#define FLASH_IT_WRPERR_BANK1 FLASH_CR_WRPERRIE
263#define FLASH_IT_PGSERR_BANK1 FLASH_CR_PGSERRIE
264#define FLASH_IT_STRBERR_BANK1 FLASH_CR_STRBERRIE
265#define FLASH_IT_INCERR_BANK1 FLASH_CR_INCERRIE
266#if defined (FLASH_CR_OPERRIE)
267#define FLASH_IT_OPERR_BANK1 FLASH_CR_OPERRIE
268#endif /* FLASH_CR_OPERRIE */
269#define FLASH_IT_RDPERR_BANK1 FLASH_CR_RDPERRIE
270#define FLASH_IT_RDSERR_BANK1 FLASH_CR_RDSERRIE
271#define FLASH_IT_SNECCERR_BANK1 FLASH_CR_SNECCERRIE
272#define FLASH_IT_DBECCERR_BANK1 FLASH_CR_DBECCERRIE
273#define FLASH_IT_CRCEND_BANK1 FLASH_CR_CRCENDIE
274#define FLASH_IT_CRCRDERR_BANK1 FLASH_CR_CRCRDERRIE
276#if defined (FLASH_CR_OPERRIE)
277#define FLASH_IT_ALL_BANK1 (FLASH_IT_EOP_BANK1 | FLASH_IT_WRPERR_BANK1 | \
278 FLASH_IT_PGSERR_BANK1 | FLASH_IT_STRBERR_BANK1 | \
279 FLASH_IT_INCERR_BANK1 | FLASH_IT_OPERR_BANK1 | \
280 FLASH_IT_RDPERR_BANK1 | FLASH_IT_RDSERR_BANK1 | \
281 FLASH_IT_SNECCERR_BANK1 | FLASH_IT_DBECCERR_BANK1 | \
282 FLASH_IT_CRCEND_BANK1 | FLASH_IT_CRCRDERR_BANK1)
283#else
284#define FLASH_IT_ALL_BANK1 (FLASH_IT_EOP_BANK1 | FLASH_IT_WRPERR_BANK1 | \
285 FLASH_IT_PGSERR_BANK1 | FLASH_IT_STRBERR_BANK1 | \
286 FLASH_IT_INCERR_BANK1 | FLASH_IT_RDPERR_BANK1 | \
287 FLASH_IT_RDSERR_BANK1 | FLASH_IT_SNECCERR_BANK1 | \
288 FLASH_IT_DBECCERR_BANK1 | FLASH_IT_CRCEND_BANK1 | \
289 FLASH_IT_CRCRDERR_BANK1)
290#endif /* FLASH_CR_OPERRIE */
291
292#define FLASH_IT_EOP_BANK2 (FLASH_CR_EOPIE | 0x80000000U)
293#define FLASH_IT_WRPERR_BANK2 (FLASH_CR_WRPERRIE | 0x80000000U)
294#define FLASH_IT_PGSERR_BANK2 (FLASH_CR_PGSERRIE | 0x80000000U)
295#define FLASH_IT_STRBERR_BANK2 (FLASH_CR_STRBERRIE | 0x80000000U)
296#define FLASH_IT_INCERR_BANK2 (FLASH_CR_INCERRIE | 0x80000000U)
297#if defined (FLASH_CR_OPERRIE)
298#define FLASH_IT_OPERR_BANK2 (FLASH_CR_OPERRIE | 0x80000000U)
299#endif /* FLASH_CR_OPERRIE */
300#define FLASH_IT_RDPERR_BANK2 (FLASH_CR_RDPERRIE | 0x80000000U)
301#define FLASH_IT_RDSERR_BANK2 (FLASH_CR_RDSERRIE | 0x80000000U)
302#define FLASH_IT_SNECCERR_BANK2 (FLASH_CR_SNECCERRIE | 0x80000000U)
303#define FLASH_IT_DBECCERR_BANK2 (FLASH_CR_DBECCERRIE | 0x80000000U)
304#define FLASH_IT_CRCEND_BANK2 (FLASH_CR_CRCENDIE | 0x80000000U)
305#define FLASH_IT_CRCRDERR_BANK2 (FLASH_CR_CRCRDERRIE | 0x80000000U)
307#if defined (FLASH_CR_OPERRIE)
308#define FLASH_IT_ALL_BANK2 (FLASH_IT_EOP_BANK2 | FLASH_IT_WRPERR_BANK2 | \
309 FLASH_IT_PGSERR_BANK2 | FLASH_IT_STRBERR_BANK2 | \
310 FLASH_IT_INCERR_BANK2 | FLASH_IT_OPERR_BANK2 | \
311 FLASH_IT_RDPERR_BANK2 | FLASH_IT_RDSERR_BANK2 | \
312 FLASH_IT_SNECCERR_BANK2 | FLASH_IT_DBECCERR_BANK2 | \
313 FLASH_IT_CRCEND_BANK2 | FLASH_IT_CRCRDERR_BANK2)
314#else
315#define FLASH_IT_ALL_BANK2 (FLASH_IT_EOP_BANK2 | FLASH_IT_WRPERR_BANK2 | \
316 FLASH_IT_PGSERR_BANK2 | FLASH_IT_STRBERR_BANK2 | \
317 FLASH_IT_INCERR_BANK2 | FLASH_IT_RDPERR_BANK2 | \
318 FLASH_IT_RDSERR_BANK2 | FLASH_IT_SNECCERR_BANK2 | \
319 FLASH_IT_DBECCERR_BANK2 | FLASH_IT_CRCEND_BANK2 | \
320 FLASH_IT_CRCRDERR_BANK2)
321#endif /* FLASH_CR_OPERRIE */
326#if defined (FLASH_CR_PSIZE)
331#define FLASH_PSIZE_BYTE 0x00000000U
332#define FLASH_PSIZE_HALF_WORD FLASH_CR_PSIZE_0
333#define FLASH_PSIZE_WORD FLASH_CR_PSIZE_1
334#define FLASH_PSIZE_DOUBLE_WORD FLASH_CR_PSIZE
338#endif /* FLASH_CR_PSIZE */
339
340
345#define FLASH_KEY1 0x45670123U
346#define FLASH_KEY2 0xCDEF89ABU
347#define FLASH_OPT_KEY1 0x08192A3BU
348#define FLASH_OPT_KEY2 0x4C5D6E7FU
357#define FLASH_SECTOR_0 0U
358#define FLASH_SECTOR_1 1U
359#define FLASH_SECTOR_2 2U
360#define FLASH_SECTOR_3 3U
361#define FLASH_SECTOR_4 4U
362#define FLASH_SECTOR_5 5U
363#define FLASH_SECTOR_6 6U
364#define FLASH_SECTOR_7 7U
365#if (FLASH_SECTOR_TOTAL == 128)
366#define FLASH_SECTOR_8 8U
367#define FLASH_SECTOR_9 9U
368#define FLASH_SECTOR_10 10U
369#define FLASH_SECTOR_11 11U
370#define FLASH_SECTOR_12 12U
371#define FLASH_SECTOR_13 13U
372#define FLASH_SECTOR_14 14U
373#define FLASH_SECTOR_15 15U
374#define FLASH_SECTOR_16 16U
375#define FLASH_SECTOR_17 17U
376#define FLASH_SECTOR_18 18U
377#define FLASH_SECTOR_19 19U
378#define FLASH_SECTOR_20 20U
379#define FLASH_SECTOR_21 21U
380#define FLASH_SECTOR_22 22U
381#define FLASH_SECTOR_23 23U
382#define FLASH_SECTOR_24 24U
383#define FLASH_SECTOR_25 25U
384#define FLASH_SECTOR_26 26U
385#define FLASH_SECTOR_27 27U
386#define FLASH_SECTOR_28 28U
387#define FLASH_SECTOR_29 29U
388#define FLASH_SECTOR_30 30U
389#define FLASH_SECTOR_31 31U
390#define FLASH_SECTOR_32 32U
391#define FLASH_SECTOR_33 33U
392#define FLASH_SECTOR_34 34U
393#define FLASH_SECTOR_35 35U
394#define FLASH_SECTOR_36 36U
395#define FLASH_SECTOR_37 37U
396#define FLASH_SECTOR_38 38U
397#define FLASH_SECTOR_39 39U
398#define FLASH_SECTOR_40 40U
399#define FLASH_SECTOR_41 41U
400#define FLASH_SECTOR_42 42U
401#define FLASH_SECTOR_43 43U
402#define FLASH_SECTOR_44 44U
403#define FLASH_SECTOR_45 45U
404#define FLASH_SECTOR_46 46U
405#define FLASH_SECTOR_47 47U
406#define FLASH_SECTOR_48 48U
407#define FLASH_SECTOR_49 49U
408#define FLASH_SECTOR_50 50U
409#define FLASH_SECTOR_51 51U
410#define FLASH_SECTOR_52 52U
411#define FLASH_SECTOR_53 53U
412#define FLASH_SECTOR_54 54U
413#define FLASH_SECTOR_55 55U
414#define FLASH_SECTOR_56 56U
415#define FLASH_SECTOR_57 57U
416#define FLASH_SECTOR_58 58U
417#define FLASH_SECTOR_59 59U
418#define FLASH_SECTOR_60 60U
419#define FLASH_SECTOR_61 61U
420#define FLASH_SECTOR_62 62U
421#define FLASH_SECTOR_63 63U
422#define FLASH_SECTOR_64 64U
423#define FLASH_SECTOR_65 65U
424#define FLASH_SECTOR_66 66U
425#define FLASH_SECTOR_67 67U
426#define FLASH_SECTOR_68 68U
427#define FLASH_SECTOR_69 69U
428#define FLASH_SECTOR_70 70U
429#define FLASH_SECTOR_71 71U
430#define FLASH_SECTOR_72 72U
431#define FLASH_SECTOR_73 73U
432#define FLASH_SECTOR_74 74U
433#define FLASH_SECTOR_75 75U
434#define FLASH_SECTOR_76 76U
435#define FLASH_SECTOR_77 77U
436#define FLASH_SECTOR_78 78U
437#define FLASH_SECTOR_79 79U
438#define FLASH_SECTOR_80 80U
439#define FLASH_SECTOR_81 81U
440#define FLASH_SECTOR_82 82U
441#define FLASH_SECTOR_83 83U
442#define FLASH_SECTOR_84 84U
443#define FLASH_SECTOR_85 85U
444#define FLASH_SECTOR_86 86U
445#define FLASH_SECTOR_87 87U
446#define FLASH_SECTOR_88 88U
447#define FLASH_SECTOR_89 89U
448#define FLASH_SECTOR_90 90U
449#define FLASH_SECTOR_91 91U
450#define FLASH_SECTOR_92 92U
451#define FLASH_SECTOR_93 93U
452#define FLASH_SECTOR_94 94U
453#define FLASH_SECTOR_95 95U
454#define FLASH_SECTOR_96 96U
455#define FLASH_SECTOR_97 97U
456#define FLASH_SECTOR_98 98U
457#define FLASH_SECTOR_99 99U
458#define FLASH_SECTOR_100 100U
459#define FLASH_SECTOR_101 101U
460#define FLASH_SECTOR_102 102U
461#define FLASH_SECTOR_103 103U
462#define FLASH_SECTOR_104 104U
463#define FLASH_SECTOR_105 105U
464#define FLASH_SECTOR_106 106U
465#define FLASH_SECTOR_107 107U
466#define FLASH_SECTOR_108 108U
467#define FLASH_SECTOR_109 109U
468#define FLASH_SECTOR_110 110U
469#define FLASH_SECTOR_111 111U
470#define FLASH_SECTOR_112 112U
471#define FLASH_SECTOR_113 113U
472#define FLASH_SECTOR_114 114U
473#define FLASH_SECTOR_115 115U
474#define FLASH_SECTOR_116 116U
475#define FLASH_SECTOR_117 117U
476#define FLASH_SECTOR_118 118U
477#define FLASH_SECTOR_119 119U
478#define FLASH_SECTOR_120 120U
479#define FLASH_SECTOR_121 121U
480#define FLASH_SECTOR_122 122U
481#define FLASH_SECTOR_123 123U
482#define FLASH_SECTOR_124 124U
483#define FLASH_SECTOR_125 125U
484#define FLASH_SECTOR_126 126U
485#define FLASH_SECTOR_127 127U
486#endif /* FLASH_SECTOR_TOTAL == 128 */
495/* Exported macro ------------------------------------------------------------*/
506#define __HAL_FLASH_SET_LATENCY(__LATENCY__) \
507 MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(__LATENCY__))
508
514#define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))
515
551#define __HAL_FLASH_ENABLE_IT_BANK1(__INTERRUPT__) (FLASH->CR1 |= (__INTERRUPT__))
552
553#define __HAL_FLASH_ENABLE_IT_BANK2(__INTERRUPT__) (FLASH->CR2 |= ((__INTERRUPT__) & 0x7FFFFFFFU))
554
555#if defined (DUAL_BANK)
556#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) (IS_FLASH_IT_BANK1(__INTERRUPT__) ? \
557 __HAL_FLASH_ENABLE_IT_BANK1(__INTERRUPT__) : \
558 __HAL_FLASH_ENABLE_IT_BANK2(__INTERRUPT__))
559#else
560#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) __HAL_FLASH_ENABLE_IT_BANK1(__INTERRUPT__)
561#endif /* DUAL_BANK */
562
563
599#define __HAL_FLASH_DISABLE_IT_BANK1(__INTERRUPT__) (FLASH->CR1 &= ~(uint32_t)(__INTERRUPT__))
600
601#define __HAL_FLASH_DISABLE_IT_BANK2(__INTERRUPT__) (FLASH->CR2 &= ~(uint32_t)((__INTERRUPT__) & 0x7FFFFFFFU))
602
603#if defined (DUAL_BANK)
604#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) (IS_FLASH_IT_BANK1(__INTERRUPT__) ? \
605 __HAL_FLASH_DISABLE_IT_BANK1(__INTERRUPT__) : \
606 __HAL_FLASH_DISABLE_IT_BANK2(__INTERRUPT__))
607#else
608#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) __HAL_FLASH_DISABLE_IT_BANK1(__INTERRUPT__)
609#endif /* DUAL_BANK */
610
611
652#define __HAL_FLASH_GET_FLAG_BANK1(__FLAG__) (READ_BIT(FLASH->SR1, (__FLAG__)) == (__FLAG__))
653
654#define __HAL_FLASH_GET_FLAG_BANK2(__FLAG__) (READ_BIT(FLASH->SR2, ((__FLAG__) & 0x7FFFFFFFU)) == (((__FLAG__) & 0x7FFFFFFFU)))
655
656#if defined (DUAL_BANK)
657#define __HAL_FLASH_GET_FLAG(__FLAG__) (IS_FLASH_FLAG_BANK1(__FLAG__) ? __HAL_FLASH_GET_FLAG_BANK1(__FLAG__) : \
658 __HAL_FLASH_GET_FLAG_BANK2(__FLAG__))
659#else
660#define __HAL_FLASH_GET_FLAG(__FLAG__) __HAL_FLASH_GET_FLAG_BANK1(__FLAG__)
661#endif /* DUAL_BANK */
662
663
701#define __HAL_FLASH_CLEAR_FLAG_BANK1(__FLAG__) WRITE_REG(FLASH->CCR1, (__FLAG__))
702
703#define __HAL_FLASH_CLEAR_FLAG_BANK2(__FLAG__) WRITE_REG(FLASH->CCR2, ((__FLAG__) & 0x7FFFFFFFU))
704
705#if defined (DUAL_BANK)
706#define __HAL_FLASH_CLEAR_FLAG(__FLAG__) (IS_FLASH_FLAG_BANK1(__FLAG__) ? __HAL_FLASH_CLEAR_FLAG_BANK1(__FLAG__) : \
707 __HAL_FLASH_CLEAR_FLAG_BANK2(__FLAG__))
708#else
709#define __HAL_FLASH_CLEAR_FLAG(__FLAG__) __HAL_FLASH_CLEAR_FLAG_BANK1(__FLAG__)
710#endif /* DUAL_BANK */
711
716/* Include FLASH HAL Extension module */
718
719/* Exported functions --------------------------------------------------------*/
726/* Program operation functions ***********************************************/
727HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress);
728HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress);
729/* FLASH IRQ handler method */
730void HAL_FLASH_IRQHandler(void);
731/* Callbacks in non blocking modes */
732void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
733void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
741/* Peripheral Control functions **********************************************/
742HAL_StatusTypeDef HAL_FLASH_Unlock(void);
743HAL_StatusTypeDef HAL_FLASH_Lock(void);
744HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
745HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
746/* Option bytes control */
747HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
755/* Peripheral State functions ************************************************/
756uint32_t HAL_FLASH_GetError(void);
764/* Private types -------------------------------------------------------------*/
765/* Private variables ---------------------------------------------------------*/
770extern FLASH_ProcessTypeDef pFlash;
774/* Private constants ---------------------------------------------------------*/
784/* Private macros ------------------------------------------------------------*/
790#if defined (FLASH_OPTCR_PG_OTP)
791#define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_FLASHWORD) || \
792 ((VALUE) == FLASH_TYPEPROGRAM_OTPWORD))
793#else
794#define IS_FLASH_TYPEPROGRAM(VALUE) ((VALUE) == FLASH_TYPEPROGRAM_FLASHWORD)
795#endif /* FLASH_OPTCR_PG_OTP */
796
797#define IS_FLASH_IT_BANK1(IT) (((IT) & FLASH_IT_ALL_BANK1) == (IT))
798#if defined (DUAL_BANK)
799#define IS_FLASH_IT_BANK2(IT) (((IT) & FLASH_IT_ALL_BANK2) == (IT))
800#endif /* DUAL_BANK */
801
802#define IS_FLASH_FLAG_BANK1(FLAG) (((FLAG) & FLASH_FLAG_ALL_BANK1) == (FLAG))
803#if defined (DUAL_BANK)
804#define IS_FLASH_FLAG_BANK2(FLAG) (((FLAG) & FLASH_FLAG_ALL_BANK2) == (FLAG))
805#endif /* DUAL_BANK */
806
807#if defined (DUAL_BANK)
808#define IS_FLASH_PROGRAM_ADDRESS_BANK1(ADDRESS) (((ADDRESS) >= FLASH_BANK1_BASE) && ((ADDRESS) < FLASH_BANK2_BASE))
809#define IS_FLASH_PROGRAM_ADDRESS_BANK2(ADDRESS) (((ADDRESS) >= FLASH_BANK2_BASE ) && ((ADDRESS) <= FLASH_END))
810#else
811#define IS_FLASH_PROGRAM_ADDRESS_BANK1(ADDRESS) (((ADDRESS) >= FLASH_BANK1_BASE) && ((ADDRESS) <= FLASH_END))
812#endif /* DUAL_BANK */
813
814#if defined (DUAL_BANK)
815#if defined (FLASH_OPTCR_PG_OTP)
816#define IS_FLASH_PROGRAM_ADDRESS_OTP(ADDRESS) (((ADDRESS) >= 0x08FFF000U) && ((ADDRESS) <= 0x08FFF3FFU))
817#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (IS_FLASH_PROGRAM_ADDRESS_BANK1(ADDRESS) || \
818 IS_FLASH_PROGRAM_ADDRESS_BANK2(ADDRESS) || \
819 IS_FLASH_PROGRAM_ADDRESS_OTP(ADDRESS))
820#else
821#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (IS_FLASH_PROGRAM_ADDRESS_BANK1(ADDRESS) || \
822 IS_FLASH_PROGRAM_ADDRESS_BANK2(ADDRESS))
823#endif /* FLASH_OPTCR_PG_OTP */
824#else
825#if defined (FLASH_OPTCR_PG_OTP)
826#define IS_FLASH_PROGRAM_ADDRESS_OTP(ADDRESS) (((ADDRESS) >= 0x08FFF000U) && ((ADDRESS) <= 0x08FFF3FFU))
827#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (IS_FLASH_PROGRAM_ADDRESS_BANK1(ADDRESS) || \
828 IS_FLASH_PROGRAM_ADDRESS_OTP(ADDRESS))
829#else
830#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (IS_FLASH_PROGRAM_ADDRESS_BANK1(ADDRESS))
831#endif /* FLASH_OPTCR_PG_OTP */
832#endif /* DUAL_BANK */
833
834#define IS_BOOT_ADDRESS(ADDRESS) ((ADDRESS) <= (0x3FFF0000U))
835
836#if defined (DUAL_BANK)
837#define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
838 ((BANK) == FLASH_BANK_2) || \
839 ((BANK) == FLASH_BANK_BOTH))
840#define IS_FLASH_BANK_EXCLUSIVE(BANK) (((BANK) == FLASH_BANK_1) || \
841 ((BANK) == FLASH_BANK_2))
842#else
843#define IS_FLASH_BANK(BANK) ((BANK) == FLASH_BANK_1)
844#define IS_FLASH_BANK_EXCLUSIVE(BANK) ((BANK) == FLASH_BANK_1)
845#endif /* DUAL_BANK */
846
850/* Private functions ---------------------------------------------------------*/
855HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout, uint32_t Bank);
856HAL_StatusTypeDef FLASH_OB_WaitForLastOperation(uint32_t Timeout);
857HAL_StatusTypeDef FLASH_CRC_WaitForLastOperation(uint32_t Timeout, uint32_t Bank);
870#ifdef __cplusplus
871}
872#endif
873
874#endif /* STM32H7xx_HAL_FLASH_H */
875
#define __IO
Definition: core_cm4.h:239
FLASH_ProcedureTypeDef
FLASH Procedure structure definition.
Definition: stm32h7xx_hal_flash.h:47
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of FLASH HAL module.
FLASH handle Structure definition.
Definition: stm32h7xx_hal_flash.h:63
__IO uint32_t Sector
Definition: stm32h7xx_hal_flash.h:70
__IO uint32_t NbSectorsToErase
Definition: stm32h7xx_hal_flash.h:66
__IO uint32_t VoltageForErase
Definition: stm32h7xx_hal_flash.h:68
__IO uint32_t Address
Definition: stm32h7xx_hal_flash.h:72
__IO uint32_t ErrorCode
Definition: stm32h7xx_hal_flash.h:76
HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_flash.h:74
__IO FLASH_ProcedureTypeDef ProcedureOnGoing
Definition: stm32h7xx_hal_flash.h:64