STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
stm32h7xx_hal_flash.c
Go to the documentation of this file.
1/**
2 ******************************************************************************
3 * @file stm32h7xx_hal_flash.c
4 * @author MCD Application Team
5 * @brief FLASH HAL module driver.
6 * This file provides firmware functions to manage the following
7 * functionalities of the internal FLASH memory:
8 * + Program operations functions
9 * + Memory Control functions
10 * + Peripheral Errors functions
11 *
12 @verbatim
13 ==============================================================================
14 ##### FLASH peripheral features #####
15 ==============================================================================
16
17 [..] The Flash memory interface manages CPU AXI I-Code and D-Code accesses
18 to the Flash memory. It implements the erase and program Flash memory operations
19 and the read and write protection mechanisms.
20
21 [..] The FLASH main features are:
22 (+) Flash memory read operations
23 (+) Flash memory program/erase operations
24 (+) Read / write protections
25 (+) Option bytes programming
26 (+) Error code correction (ECC) : Data in flash are 266-bits word
27 (10 bits added per flash word)
28
29 ##### How to use this driver #####
30 ==============================================================================
31 [..]
32 This driver provides functions and macros to configure and program the FLASH
33 memory of all STM32H7xx devices.
34
35 (#) FLASH Memory IO Programming functions:
36 (++) Lock and Unlock the FLASH interface using HAL_FLASH_Unlock() and
37 HAL_FLASH_Lock() functions
38 (++) Program functions: 256-bit word only
39 (++) There Two modes of programming :
40 (+++) Polling mode using HAL_FLASH_Program() function
41 (+++) Interrupt mode using HAL_FLASH_Program_IT() function
42
43 (#) Interrupts and flags management functions :
44 (++) Handle FLASH interrupts by calling HAL_FLASH_IRQHandler()
45 (++) Callback functions are called when the flash operations are finished :
46 HAL_FLASH_EndOfOperationCallback() when everything is ok, otherwise
47 HAL_FLASH_OperationErrorCallback()
48 (++) Get error flag status by calling HAL_FLASH_GetError()
49
50 (#) Option bytes management functions :
51 (++) Lock and Unlock the option bytes using HAL_FLASH_OB_Unlock() and
52 HAL_FLASH_OB_Lock() functions
53 (++) Launch the reload of the option bytes using HAL_FLASH_OB_Launch() function.
54 In this case, a reset is generated
55 [..]
56 In addition to these functions, this driver includes a set of macros allowing
57 to handle the following operations:
58 (+) Set the latency
59 (+) Enable/Disable the FLASH interrupts
60 (+) Monitor the FLASH flags status
61 [..]
62 (@) For any Flash memory program operation (erase or program), the CPU clock frequency
63 (HCLK) must be at least 1MHz.
64 (@) The contents of the Flash memory are not guaranteed if a device reset occurs during
65 a Flash memory operation.
66 (@) The application can simultaneously request a read and a write operation through each AXI
67 interface.
68 As the Flash memory is divided into two independent banks, the embedded Flash
69 memory interface can drive different operations at the same time on each bank. For
70 example a read, write or erase operation can be executed on bank 1 while another read,
71 write or erase operation is executed on bank 2.
72
73 @endverbatim
74 ******************************************************************************
75 * @attention
76 *
77 * Copyright (c) 2017 STMicroelectronics.
78 * All rights reserved.
79 *
80 * This software is licensed under terms that can be found in the LICENSE file in
81 * the root directory of this software component.
82 * If no LICENSE file comes with this software, it is provided AS-IS.
83 ******************************************************************************
84 */
85
86/* Includes ------------------------------------------------------------------*/
87#include "stm32h7xx_hal.h"
88
89/** @addtogroup STM32H7xx_HAL_Driver
90 * @{
91 */
92
93/** @defgroup FLASH FLASH
94 * @brief FLASH HAL module driver
95 * @{
96 */
97
98#ifdef HAL_FLASH_MODULE_ENABLED
99
100/* Private typedef -----------------------------------------------------------*/
101/* Private define ------------------------------------------------------------*/
102/** @addtogroup FLASH_Private_Constants
103 * @{
104 */
105#define FLASH_TIMEOUT_VALUE 50000U /* 50 s */
106/**
107 * @}
108 */
109/* Private macro -------------------------------------------------------------*/
110/* Private variables ---------------------------------------------------------*/
111/** @addtogroup FLASH_Private_Variables
112 * @{
113 */
114FLASH_ProcessTypeDef pFlash = {.ProcedureOnGoing = FLASH_PROC_NONE,
115 .NbSectorsToErase = 0U,
116 .VoltageForErase= 0U,
117 .Sector = 0U,
118 .Address = 0U,
119 .Lock = HAL_UNLOCKED,
120 .ErrorCode = HAL_FLASH_ERROR_NONE};
121/**
122 * @}
123 */
124/* Private function prototypes -----------------------------------------------*/
125/* Exported functions ---------------------------------------------------------*/
126
127/** @defgroup FLASH_Exported_Functions FLASH Exported functions
128 * @{
129 */
130
131/** @defgroup FLASH_Exported_Functions_Group1 Programming operation functions
132 * @brief Programming operation functions
133 *
134@verbatim
135 ===============================================================================
136 ##### Programming operation functions #####
137 ===============================================================================
138 [..]
139 This subsection provides a set of functions allowing to manage the FLASH
140 program operations.
141
142@endverbatim
143 * @{
144 */
145
146/**
147 * @brief Program a flash word at a specified address
148 * @param TypeProgram Indicate the way to program at a specified address.
149 * This parameter can be a value of @ref FLASH_Type_Program
150 * @param FlashAddress specifies the address to be programmed.
151 * This parameter shall be aligned to the Flash word:
152 * - 256 bits for STM32H74x/5X devices (8x 32bits words)
153 * - 128 bits for STM32H7Ax/BX devices (4x 32bits words)
154 * - 256 bits for STM32H72x/3X devices (8x 32bits words)
155 * @param DataAddress specifies the address of data to be programmed.
156 * This parameter shall be 32-bit aligned
157 *
158 * @retval HAL_StatusTypeDef HAL Status
159 */
160HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress)
161{
163 __IO uint32_t *dest_addr = (__IO uint32_t *)FlashAddress;
164 __IO uint32_t *src_addr = (__IO uint32_t*)DataAddress;
165 uint32_t bank;
166 uint8_t row_index = FLASH_NB_32BITWORD_IN_FLASHWORD;
167
168 /* Check the parameters */
171
172 /* Process Locked */
174
175#if defined (FLASH_OPTCR_PG_OTP)
176 if((IS_FLASH_PROGRAM_ADDRESS_BANK1(FlashAddress)) || (IS_FLASH_PROGRAM_ADDRESS_OTP(FlashAddress)))
177#else
178 if(IS_FLASH_PROGRAM_ADDRESS_BANK1(FlashAddress))
179#endif /* FLASH_OPTCR_PG_OTP */
180 {
181 bank = FLASH_BANK_1;
182 /* Prevent unused argument(s) compilation warning */
183 UNUSED(TypeProgram);
184 }
185#if defined (DUAL_BANK)
186 else if(IS_FLASH_PROGRAM_ADDRESS_BANK2(FlashAddress))
187 {
188 bank = FLASH_BANK_2;
189 }
190#endif /* DUAL_BANK */
191 else
192 {
193 return HAL_ERROR;
194 }
195
196 /* Reset error code */
197 pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
198
199 /* Wait for last operation to be completed */
200 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, bank);
201
202 if(status == HAL_OK)
203 {
204#if defined (DUAL_BANK)
205 if(bank == FLASH_BANK_1)
206 {
207#if defined (FLASH_OPTCR_PG_OTP)
208 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
209 {
210 /* Set OTP_PG bit */
211 SET_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
212 }
213 else
214#endif /* FLASH_OPTCR_PG_OTP */
215 {
216 /* Set PG bit */
218 }
219 }
220 else
221 {
222 /* Set PG bit */
224 }
225#else /* Single Bank */
226#if defined (FLASH_OPTCR_PG_OTP)
227 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
228 {
229 /* Set OTP_PG bit */
230 SET_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
231 }
232 else
233#endif /* FLASH_OPTCR_PG_OTP */
234 {
235 /* Set PG bit */
237 }
238#endif /* DUAL_BANK */
239
240 __ISB();
241 __DSB();
242
243#if defined (FLASH_OPTCR_PG_OTP)
244 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
245 {
246 /* Program an OTP word (16 bits) */
247 *(__IO uint16_t *)FlashAddress = *(__IO uint16_t*)DataAddress;
248 }
249 else
250#endif /* FLASH_OPTCR_PG_OTP */
251 {
252 /* Program the flash word */
253 do
254 {
255 *dest_addr = *src_addr;
256 dest_addr++;
257 src_addr++;
258 row_index--;
259 } while (row_index != 0U);
260 }
261
262 __ISB();
263 __DSB();
264
265 /* Wait for last operation to be completed */
266 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, bank);
267
268#if defined (DUAL_BANK)
269#if defined (FLASH_OPTCR_PG_OTP)
270 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
271 {
272 /* If the program operation is completed, disable the OTP_PG */
273 CLEAR_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
274 }
275 else
276#endif /* FLASH_OPTCR_PG_OTP */
277 {
278 if(bank == FLASH_BANK_1)
279 {
280 /* If the program operation is completed, disable the PG */
282 }
283 else
284 {
285 /* If the program operation is completed, disable the PG */
287 }
288 }
289#else /* Single Bank */
290#if defined (FLASH_OPTCR_PG_OTP)
291 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
292 {
293 /* If the program operation is completed, disable the OTP_PG */
294 CLEAR_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
295 }
296 else
297#endif /* FLASH_OPTCR_PG_OTP */
298 {
299 /* If the program operation is completed, disable the PG */
301 }
302#endif /* DUAL_BANK */
303 }
304
305 /* Process Unlocked */
307
308 return status;
309}
310
311/**
312 * @brief Program a flash word at a specified address with interrupt enabled.
313 * @param TypeProgram Indicate the way to program at a specified address.
314 * This parameter can be a value of @ref FLASH_Type_Program
315 * @param FlashAddress specifies the address to be programmed.
316 * This parameter shall be aligned to the Flash word:
317 * - 256 bits for STM32H74x/5X devices (8x 32bits words)
318 * - 128 bits for STM32H7Ax/BX devices (4x 32bits words)
319 * - 256 bits for STM32H72x/3X devices (8x 32bits words)
320 * @param DataAddress specifies the address of data to be programmed.
321 * This parameter shall be 32-bit aligned
322 *
323 * @retval HAL Status
324 */
325HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress)
326{
328 __IO uint32_t *dest_addr = (__IO uint32_t*)FlashAddress;
329 __IO uint32_t *src_addr = (__IO uint32_t*)DataAddress;
330 uint32_t bank;
331 uint8_t row_index = FLASH_NB_32BITWORD_IN_FLASHWORD;
332
333 /* Check the parameters */
336
337 /* Process Locked */
339
340 /* Reset error code */
341 pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
342
343#if defined (FLASH_OPTCR_PG_OTP)
344 if((IS_FLASH_PROGRAM_ADDRESS_BANK1(FlashAddress)) || (IS_FLASH_PROGRAM_ADDRESS_OTP(FlashAddress)))
345#else
346 if(IS_FLASH_PROGRAM_ADDRESS_BANK1(FlashAddress))
347#endif /* FLASH_OPTCR_PG_OTP */
348 {
349 bank = FLASH_BANK_1;
350 /* Prevent unused argument(s) compilation warning */
351 UNUSED(TypeProgram);
352 }
353#if defined (DUAL_BANK)
354 else if(IS_FLASH_PROGRAM_ADDRESS_BANK2(FlashAddress))
355 {
356 bank = FLASH_BANK_2;
357 }
358#endif /* DUAL_BANK */
359 else
360 {
361 return HAL_ERROR;
362 }
363
364 /* Wait for last operation to be completed */
365 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, bank);
366
367 if (status != HAL_OK)
368 {
369 /* Process Unlocked */
371 }
372 else
373 {
374 pFlash.Address = FlashAddress;
375
376#if defined (DUAL_BANK)
377 if(bank == FLASH_BANK_1)
378 {
379 /* Set internal variables used by the IRQ handler */
380 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM_BANK1;
381
382#if defined (FLASH_OPTCR_PG_OTP)
383 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
384 {
385 /* Set OTP_PG bit */
386 SET_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
387 }
388 else
389#endif /* FLASH_OPTCR_PG_OTP */
390 {
391 /* Set PG bit */
393 }
394
395 /* Enable End of Operation and Error interrupts for Bank 1 */
396#if defined (FLASH_CR_OPERRIE)
398 FLASH_IT_STRBERR_BANK1 | FLASH_IT_INCERR_BANK1 | FLASH_IT_OPERR_BANK1);
399#else
402#endif /* FLASH_CR_OPERRIE */
403 }
404 else
405 {
406 /* Set internal variables used by the IRQ handler */
407 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM_BANK2;
408
409 /* Set PG bit */
411
412 /* Enable End of Operation and Error interrupts for Bank2 */
413#if defined (FLASH_CR_OPERRIE)
415 FLASH_IT_STRBERR_BANK2 | FLASH_IT_INCERR_BANK2 | FLASH_IT_OPERR_BANK2);
416#else
419#endif /* FLASH_CR_OPERRIE */
420 }
421#else /* Single Bank */
422 /* Set internal variables used by the IRQ handler */
423 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM_BANK1;
424
425#if defined (FLASH_OPTCR_PG_OTP)
426 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
427 {
428 /* Set OTP_PG bit */
429 SET_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
430 }
431 else
432#endif /* FLASH_OPTCR_PG_OTP */
433 {
434 /* Set PG bit */
436 }
437
438 /* Enable End of Operation and Error interrupts for Bank 1 */
439#if defined (FLASH_CR_OPERRIE)
441 FLASH_IT_STRBERR_BANK1 | FLASH_IT_INCERR_BANK1 | FLASH_IT_OPERR_BANK1);
442#else
445#endif /* FLASH_CR_OPERRIE */
446#endif /* DUAL_BANK */
447
448 __ISB();
449 __DSB();
450
451#if defined (FLASH_OPTCR_PG_OTP)
452 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
453 {
454 /* Program an OTP word (16 bits) */
455 *(__IO uint16_t *)FlashAddress = *(__IO uint16_t*)DataAddress;
456 }
457 else
458#endif /* FLASH_OPTCR_PG_OTP */
459 {
460 /* Program the flash word */
461 do
462 {
463 *dest_addr = *src_addr;
464 dest_addr++;
465 src_addr++;
466 row_index--;
467 } while (row_index != 0U);
468 }
469
470 __ISB();
471 __DSB();
472 }
473
474 return status;
475}
476
477/**
478 * @brief This function handles FLASH interrupt request.
479 * @retval None
480 */
481void HAL_FLASH_IRQHandler(void)
482{
483 uint32_t temp;
484 uint32_t errorflag;
485 FLASH_ProcedureTypeDef procedure;
486
487 /* Check FLASH Bank1 End of Operation flag */
489 {
490 if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE_BANK1)
491 {
492 /* Nb of sector to erased can be decreased */
493 pFlash.NbSectorsToErase--;
494
495 /* Check if there are still sectors to erase */
496 if(pFlash.NbSectorsToErase != 0U)
497 {
498 /* Indicate user which sector has been erased */
500
501 /* Clear bank 1 End of Operation pending bit */
503
504 /* Increment sector number */
505 pFlash.Sector++;
506 temp = pFlash.Sector;
507 FLASH_Erase_Sector(temp, FLASH_BANK_1, pFlash.VoltageForErase);
508 }
509 else
510 {
511 /* No more sectors to Erase, user callback can be called */
512 /* Reset Sector and stop Erase sectors procedure */
513 pFlash.Sector = 0xFFFFFFFFU;
514 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
515
516 /* FLASH EOP interrupt user callback */
518
519 /* Clear FLASH End of Operation pending bit */
521 }
522 }
523 else
524 {
525 procedure = pFlash.ProcedureOnGoing;
526
527 if((procedure == FLASH_PROC_MASSERASE_BANK1) || (procedure == FLASH_PROC_ALLBANK_MASSERASE))
528 {
529 /* MassErase ended. Return the selected bank */
530 /* FLASH EOP interrupt user callback */
532 }
533 else if(procedure == FLASH_PROC_PROGRAM_BANK1)
534 {
535 /* Program ended. Return the selected address */
536 /* FLASH EOP interrupt user callback */
538 }
539 else
540 {
541 /* Nothing to do */
542 }
543
544 if((procedure != FLASH_PROC_SECTERASE_BANK2) && \
545 (procedure != FLASH_PROC_MASSERASE_BANK2) && \
546 (procedure != FLASH_PROC_PROGRAM_BANK2))
547 {
548 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
549 /* Clear FLASH End of Operation pending bit */
551 }
552 }
553 }
554
555#if defined (DUAL_BANK)
556 /* Check FLASH Bank2 End of Operation flag */
558 {
559 if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE_BANK2)
560 {
561 /*Nb of sector to erased can be decreased*/
562 pFlash.NbSectorsToErase--;
563
564 /* Check if there are still sectors to erase*/
565 if(pFlash.NbSectorsToErase != 0U)
566 {
567 /*Indicate user which sector has been erased*/
569
570 /* Clear bank 2 End of Operation pending bit */
572
573 /*Increment sector number*/
574 pFlash.Sector++;
575 temp = pFlash.Sector;
576 FLASH_Erase_Sector(temp, FLASH_BANK_2, pFlash.VoltageForErase);
577 }
578 else
579 {
580 /* No more sectors to Erase, user callback can be called */
581 /* Reset Sector and stop Erase sectors procedure */
582 pFlash.Sector = 0xFFFFFFFFU;
583 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
584
585 /* FLASH EOP interrupt user callback */
587
588 /* Clear FLASH End of Operation pending bit */
590 }
591 }
592 else
593 {
594 procedure = pFlash.ProcedureOnGoing;
595
596 if((procedure == FLASH_PROC_MASSERASE_BANK2) || (procedure == FLASH_PROC_ALLBANK_MASSERASE))
597 {
598 /*MassErase ended. Return the selected bank*/
599 /* FLASH EOP interrupt user callback */
601 }
602 else if(procedure == FLASH_PROC_PROGRAM_BANK2)
603 {
604 /* Program ended. Return the selected address */
605 /* FLASH EOP interrupt user callback */
607 }
608 else
609 {
610 /* Nothing to do */
611 }
612
613 if((procedure != FLASH_PROC_SECTERASE_BANK1) && \
614 (procedure != FLASH_PROC_MASSERASE_BANK1) && \
615 (procedure != FLASH_PROC_PROGRAM_BANK1))
616 {
617 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
618 /* Clear FLASH End of Operation pending bit */
620 }
621 }
622 }
623#endif /* DUAL_BANK */
624
625 /* Check FLASH Bank1 operation error flags */
626#if defined (FLASH_SR_OPERR)
628 FLASH_FLAG_INCERR_BANK1 | FLASH_FLAG_OPERR_BANK1);
629#else
632#endif /* FLASH_SR_OPERR */
633
634 if(errorflag != 0U)
635 {
636 /* Save the error code */
637 pFlash.ErrorCode |= errorflag;
638
639 /* Clear error programming flags */
641
642 procedure = pFlash.ProcedureOnGoing;
643
644 if(procedure == FLASH_PROC_SECTERASE_BANK1)
645 {
646 /* Return the faulty sector */
647 temp = pFlash.Sector;
648 pFlash.Sector = 0xFFFFFFFFU;
649 }
650 else if((procedure == FLASH_PROC_MASSERASE_BANK1) || (procedure == FLASH_PROC_ALLBANK_MASSERASE))
651 {
652 /* Return the faulty bank */
654 }
655 else
656 {
657 /* Return the faulty address */
658 temp = pFlash.Address;
659 }
660
661 /* Stop the procedure ongoing*/
662 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
663
664 /* FLASH error interrupt user callback */
666 }
667
668#if (USE_FLASH_ECC == 1U)
669 /* Check FLASH Bank1 ECC single correction error flag */
670 errorflag = FLASH->SR1 & FLASH_FLAG_SNECCERR_BANK1;
671
672 if(errorflag != 0U)
673 {
674 /* Save the error code */
675 pFlash.ErrorCode |= errorflag;
676
677 /* Call User callback */
678 HAL_FLASHEx_EccCorrectionCallback();
679
680 /* Clear FLASH Bank1 ECC single correction error flag in order to allow new ECC error record */
682 }
683
684 /* Check FLASH Bank1 ECC double detection error flag */
685 errorflag = FLASH->SR1 & FLASH_FLAG_DBECCERR_BANK1;
686
687 if(errorflag != 0U)
688 {
689 /* Save the error code */
690 pFlash.ErrorCode |= errorflag;
691
692 /* Call User callback */
693 HAL_FLASHEx_EccDetectionCallback();
694
695 /* Clear FLASH Bank1 ECC double detection error flag in order to allow new ECC error record */
697 }
698#endif /* USE_FLASH_ECC */
699
700#if defined (DUAL_BANK)
701 /* Check FLASH Bank2 operation error flags */
702#if defined (FLASH_SR_OPERR)
704 FLASH_FLAG_INCERR_BANK2 | FLASH_FLAG_OPERR_BANK2) & 0x7FFFFFFFU);
705#else
707 FLASH_FLAG_INCERR_BANK2) & 0x7FFFFFFFU);
708#endif /* FLASH_SR_OPERR */
709
710 if(errorflag != 0U)
711 {
712 /* Save the error code */
713 pFlash.ErrorCode |= (errorflag | 0x80000000U);
714
715 /* Clear error programming flags */
717
718 procedure = pFlash.ProcedureOnGoing;
719
720 if(procedure== FLASH_PROC_SECTERASE_BANK2)
721 {
722 /*return the faulty sector*/
723 temp = pFlash.Sector;
724 pFlash.Sector = 0xFFFFFFFFU;
725 }
726 else if((procedure == FLASH_PROC_MASSERASE_BANK2) || (procedure == FLASH_PROC_ALLBANK_MASSERASE))
727 {
728 /*return the faulty bank*/
729 temp = FLASH_BANK_2;
730 }
731 else
732 {
733 /*return the faulty address*/
734 temp = pFlash.Address;
735 }
736
737 /*Stop the procedure ongoing*/
738 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
739
740 /* FLASH error interrupt user callback */
742 }
743
744#if (USE_FLASH_ECC == 1U)
745 /* Check FLASH Bank2 ECC single correction error flag */
746 errorflag = FLASH->SR2 & FLASH_FLAG_SNECCERR_BANK2;
747
748 if(errorflag != 0U)
749 {
750 /* Save the error code */
751 pFlash.ErrorCode |= (errorflag | 0x80000000U);
752
753 /* Call User callback */
754 HAL_FLASHEx_EccCorrectionCallback();
755
756 /* Clear FLASH Bank2 ECC single correction error flag in order to allow new ECC error record */
758 }
759
760 /* Check FLASH Bank2 ECC double detection error flag */
761 errorflag = FLASH->SR2 & FLASH_FLAG_DBECCERR_BANK2;
762
763 if(errorflag != 0U)
764 {
765 /* Save the error code */
766 pFlash.ErrorCode |= (errorflag | 0x80000000U);
767
768 /* Call User callback */
769 HAL_FLASHEx_EccDetectionCallback();
770
771 /* Clear FLASH Bank2 ECC double detection error flag in order to allow new ECC error record */
773 }
774
775#endif /* USE_FLASH_ECC */
776#endif /* DUAL_BANK */
777
778 if(pFlash.ProcedureOnGoing == FLASH_PROC_NONE)
779 {
780#if defined (FLASH_CR_OPERRIE)
781 /* Disable Bank1 Operation and Error source interrupt */
783 FLASH_IT_STRBERR_BANK1 | FLASH_IT_INCERR_BANK1 | FLASH_IT_OPERR_BANK1);
784
785#if defined (DUAL_BANK)
786 /* Disable Bank2 Operation and Error source interrupt */
788 FLASH_IT_STRBERR_BANK2 | FLASH_IT_INCERR_BANK2 | FLASH_IT_OPERR_BANK2);
789#endif /* DUAL_BANK */
790#else
791 /* Disable Bank1 Operation and Error source interrupt */
794
795#if defined (DUAL_BANK)
796 /* Disable Bank2 Operation and Error source interrupt */
799#endif /* DUAL_BANK */
800#endif /* FLASH_CR_OPERRIE */
801
802 /* Process Unlocked */
804 }
805}
806
807/**
808 * @brief FLASH end of operation interrupt callback
809 * @param ReturnValue The value saved in this parameter depends on the ongoing procedure
810 * Mass Erase: Bank number which has been requested to erase
811 * Sectors Erase: Sector which has been erased
812 * (if 0xFFFFFFFF, it means that all the selected sectors have been erased)
813 * Program: Address which was selected for data program
814 * @retval None
815 */
816__weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue)
817{
818 /* Prevent unused argument(s) compilation warning */
819 UNUSED(ReturnValue);
820
821 /* NOTE : This function Should not be modified, when the callback is needed,
822 the HAL_FLASH_EndOfOperationCallback could be implemented in the user file
823 */
824}
825
826/**
827 * @brief FLASH operation error interrupt callback
828 * @param ReturnValue The value saved in this parameter depends on the ongoing procedure
829 * Mass Erase: Bank number which has been requested to erase
830 * Sectors Erase: Sector number which returned an error
831 * Program: Address which was selected for data program
832 * @retval None
833 */
834__weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue)
835{
836 /* Prevent unused argument(s) compilation warning */
837 UNUSED(ReturnValue);
838
839 /* NOTE : This function Should not be modified, when the callback is needed,
840 the HAL_FLASH_OperationErrorCallback could be implemented in the user file
841 */
842}
843
844/**
845 * @}
846 */
847
848/** @defgroup FLASH_Exported_Functions_Group2 Peripheral Control functions
849 * @brief Management functions
850 *
851@verbatim
852 ===============================================================================
853 ##### Peripheral Control functions #####
854 ===============================================================================
855 [..]
856 This subsection provides a set of functions allowing to control the FLASH
857 memory operations.
858
859@endverbatim
860 * @{
861 */
862
863/**
864 * @brief Unlock the FLASH control registers access
865 * @retval HAL Status
866 */
868{
869 if(READ_BIT(FLASH->CR1, FLASH_CR_LOCK) != 0U)
870 {
871 /* Authorize the FLASH Bank1 Registers access */
872 WRITE_REG(FLASH->KEYR1, FLASH_KEY1);
873 WRITE_REG(FLASH->KEYR1, FLASH_KEY2);
874
875 /* Verify Flash Bank1 is unlocked */
876 if (READ_BIT(FLASH->CR1, FLASH_CR_LOCK) != 0U)
877 {
878 return HAL_ERROR;
879 }
880 }
881
882#if defined (DUAL_BANK)
883 if(READ_BIT(FLASH->CR2, FLASH_CR_LOCK) != 0U)
884 {
885 /* Authorize the FLASH Bank2 Registers access */
886 WRITE_REG(FLASH->KEYR2, FLASH_KEY1);
887 WRITE_REG(FLASH->KEYR2, FLASH_KEY2);
888
889 /* Verify Flash Bank2 is unlocked */
890 if (READ_BIT(FLASH->CR2, FLASH_CR_LOCK) != 0U)
891 {
892 return HAL_ERROR;
893 }
894 }
895#endif /* DUAL_BANK */
896
897 return HAL_OK;
898}
899
900/**
901 * @brief Locks the FLASH control registers access
902 * @retval HAL Status
903 */
905{
906 /* Set the LOCK Bit to lock the FLASH Bank1 Control Register access */
908
909 /* Verify Flash Bank1 is locked */
910 if (READ_BIT(FLASH->CR1, FLASH_CR_LOCK) == 0U)
911 {
912 return HAL_ERROR;
913 }
914
915#if defined (DUAL_BANK)
916 /* Set the LOCK Bit to lock the FLASH Bank2 Control Register access */
918
919 /* Verify Flash Bank2 is locked */
920 if (READ_BIT(FLASH->CR2, FLASH_CR_LOCK) == 0U)
921 {
922 return HAL_ERROR;
923 }
924#endif /* DUAL_BANK */
925
926 return HAL_OK;
927}
928
929/**
930 * @brief Unlock the FLASH Option Control Registers access.
931 * @retval HAL Status
932 */
934{
935 if(READ_BIT(FLASH->OPTCR, FLASH_OPTCR_OPTLOCK) != 0U)
936 {
937 /* Authorizes the Option Byte registers programming */
938 WRITE_REG(FLASH->OPTKEYR, FLASH_OPT_KEY1);
939 WRITE_REG(FLASH->OPTKEYR, FLASH_OPT_KEY2);
940
941 /* Verify that the Option Bytes are unlocked */
942 if (READ_BIT(FLASH->OPTCR, FLASH_OPTCR_OPTLOCK) != 0U)
943 {
944 return HAL_ERROR;
945 }
946 }
947
948 return HAL_OK;
949}
950
951/**
952 * @brief Lock the FLASH Option Control Registers access.
953 * @retval HAL Status
954 */
956{
957 /* Set the OPTLOCK Bit to lock the FLASH Option Byte Registers access */
959
960 /* Verify that the Option Bytes are locked */
961 if (READ_BIT(FLASH->OPTCR, FLASH_OPTCR_OPTLOCK) == 0U)
962 {
963 return HAL_ERROR;
964 }
965
966 return HAL_OK;
967}
968
969/**
970 * @brief Launch the option bytes loading.
971 * @retval HAL Status
972 */
974{
976
977 /* Wait for CRC computation to be completed */
978 if (FLASH_CRC_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, FLASH_BANK_1) != HAL_OK)
979 {
981 }
982#if defined (DUAL_BANK)
983 else if (FLASH_CRC_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, FLASH_BANK_2) != HAL_OK)
984 {
986 }
987#endif /* DUAL_BANK */
988 else
989 {
990 status = HAL_OK;
991 }
992
993 if (status == HAL_OK)
994 {
995 /* Set OPTSTRT Bit */
997
998 /* Wait for OB change operation to be completed */
999 status = FLASH_OB_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
1000 }
1001
1002 return status;
1003}
1004
1005/**
1006 * @}
1007 */
1008
1009/** @defgroup FLASH_Exported_Functions_Group3 Peripheral State and Errors functions
1010 * @brief Peripheral Errors functions
1011 *
1012@verbatim
1013 ===============================================================================
1014 ##### Peripheral Errors functions #####
1015 ===============================================================================
1016 [..]
1017 This subsection permits to get in run-time Errors of the FLASH peripheral.
1018
1019@endverbatim
1020 * @{
1021 */
1022
1023/**
1024 * @brief Get the specific FLASH error flag.
1025 * @retval HAL_FLASH_ERRORCode The returned value can be:
1026 * @arg HAL_FLASH_ERROR_NONE : No error set
1027 *
1028 * @arg HAL_FLASH_ERROR_WRP_BANK1 : Write Protection Error on Bank 1
1029 * @arg HAL_FLASH_ERROR_PGS_BANK1 : Program Sequence Error on Bank 1
1030 * @arg HAL_FLASH_ERROR_STRB_BANK1 : Strobe Error on Bank 1
1031 * @arg HAL_FLASH_ERROR_INC_BANK1 : Inconsistency Error on Bank 1
1032 * @arg HAL_FLASH_ERROR_OPE_BANK1 : Operation Error on Bank 1
1033 * @arg HAL_FLASH_ERROR_RDP_BANK1 : Read Protection Error on Bank 1
1034 * @arg HAL_FLASH_ERROR_RDS_BANK1 : Read Secured Error on Bank 1
1035 * @arg HAL_FLASH_ERROR_SNECC_BANK1: ECC Single Correction Error on Bank 1
1036 * @arg HAL_FLASH_ERROR_DBECC_BANK1: ECC Double Detection Error on Bank 1
1037 * @arg HAL_FLASH_ERROR_CRCRD_BANK1: CRC Read Error on Bank 1
1038 *
1039 * @arg HAL_FLASH_ERROR_WRP_BANK2 : Write Protection Error on Bank 2
1040 * @arg HAL_FLASH_ERROR_PGS_BANK2 : Program Sequence Error on Bank 2
1041 * @arg HAL_FLASH_ERROR_STRB_BANK2 : Strobe Error on Bank 2
1042 * @arg HAL_FLASH_ERROR_INC_BANK2 : Inconsistency Error on Bank 2
1043 * @arg HAL_FLASH_ERROR_OPE_BANK2 : Operation Error on Bank 2
1044 * @arg HAL_FLASH_ERROR_RDP_BANK2 : Read Protection Error on Bank 2
1045 * @arg HAL_FLASH_ERROR_RDS_BANK2 : Read Secured Error on Bank 2
1046 * @arg HAL_FLASH_ERROR_SNECC_BANK2: SNECC Error on Bank 2
1047 * @arg HAL_FLASH_ERROR_DBECC_BANK2: Double Detection ECC on Bank 2
1048 * @arg HAL_FLASH_ERROR_CRCRD_BANK2: CRC Read Error on Bank 2
1049 */
1050
1051uint32_t HAL_FLASH_GetError(void)
1052{
1053 return pFlash.ErrorCode;
1054}
1055
1056/**
1057 * @}
1058 */
1059
1060/**
1061 * @}
1062 */
1063
1064/* Private functions ---------------------------------------------------------*/
1065
1066/** @addtogroup FLASH_Private_Functions
1067 * @{
1068 */
1069
1070/**
1071 * @brief Wait for a FLASH operation to complete.
1072 * @param Timeout maximum flash operation timeout
1073 * @param Bank flash FLASH_BANK_1 or FLASH_BANK_2
1074 * @retval HAL_StatusTypeDef HAL Status
1075 */
1076HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout, uint32_t Bank)
1077{
1078 /* Wait for the FLASH operation to complete by polling on QW flag to be reset.
1079 Even if the FLASH operation fails, the QW flag will be reset and an error
1080 flag will be set */
1081
1082 uint32_t bsyflag = FLASH_FLAG_QW_BANK1;
1083 uint32_t errorflag = 0;
1084 uint32_t tickstart = HAL_GetTick();
1085
1087
1088#if defined (DUAL_BANK)
1089
1090 if (Bank == FLASH_BANK_2)
1091 {
1092 /* Select bsyflag depending on Bank */
1093 bsyflag = FLASH_FLAG_QW_BANK2;
1094 }
1095#endif /* DUAL_BANK */
1096
1097 while(__HAL_FLASH_GET_FLAG(bsyflag))
1098 {
1099 if(Timeout != HAL_MAX_DELAY)
1100 {
1101 if(((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1102 {
1103 return HAL_TIMEOUT;
1104 }
1105 }
1106 }
1107
1108 /* Get Error Flags */
1109 if (Bank == FLASH_BANK_1)
1110 {
1111 errorflag = FLASH->SR1 & FLASH_FLAG_ALL_ERRORS_BANK1;
1112 }
1113#if defined (DUAL_BANK)
1114 else
1115 {
1116 errorflag = (FLASH->SR2 & FLASH_FLAG_ALL_ERRORS_BANK2) | 0x80000000U;
1117 }
1118#endif /* DUAL_BANK */
1119
1120 /* In case of error reported in Flash SR1 or SR2 register */
1121 if((errorflag & 0x7FFFFFFFU) != 0U)
1122 {
1123 /*Save the error code*/
1124 pFlash.ErrorCode |= errorflag;
1125
1126 /* Clear error programming flags */
1127 __HAL_FLASH_CLEAR_FLAG(errorflag);
1128
1129 return HAL_ERROR;
1130 }
1131
1132 /* Check FLASH End of Operation flag */
1133 if(Bank == FLASH_BANK_1)
1134 {
1136 {
1137 /* Clear FLASH End of Operation pending bit */
1139 }
1140 }
1141#if defined (DUAL_BANK)
1142 else
1143 {
1145 {
1146 /* Clear FLASH End of Operation pending bit */
1148 }
1149 }
1150#endif /* DUAL_BANK */
1151
1152 return HAL_OK;
1153}
1154
1155/**
1156 * @brief Wait for a FLASH Option Bytes change operation to complete.
1157 * @param Timeout maximum flash operation timeout
1158 * @retval HAL_StatusTypeDef HAL Status
1159 */
1161{
1162 /* Get timeout */
1163 uint32_t tickstart = HAL_GetTick();
1164
1165 /* Wait for the FLASH Option Bytes change operation to complete by polling on OPT_BUSY flag to be reset */
1166 while(READ_BIT(FLASH->OPTSR_CUR, FLASH_OPTSR_OPT_BUSY) != 0U)
1167 {
1168 if(Timeout != HAL_MAX_DELAY)
1169 {
1170 if(((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1171 {
1172 return HAL_TIMEOUT;
1173 }
1174 }
1175 }
1176
1177 /* Check option byte change error */
1178 if(READ_BIT(FLASH->OPTSR_CUR, FLASH_OPTSR_OPTCHANGEERR) != 0U)
1179 {
1180 /* Save the error code */
1181 pFlash.ErrorCode |= HAL_FLASH_ERROR_OB_CHANGE;
1182
1183 /* Clear the OB error flag */
1185
1186 return HAL_ERROR;
1187 }
1188
1189 /* If there is no error flag set */
1190 return HAL_OK;
1191}
1192
1193/**
1194 * @brief Wait for a FLASH CRC computation to complete.
1195 * @param Timeout maximum flash operation timeout
1196 * @param Bank flash FLASH_BANK_1 or FLASH_BANK_2
1197 * @retval HAL_StatusTypeDef HAL Status
1198 */
1199HAL_StatusTypeDef FLASH_CRC_WaitForLastOperation(uint32_t Timeout, uint32_t Bank)
1200{
1201 uint32_t bsyflag;
1202 uint32_t tickstart = HAL_GetTick();
1203
1205
1206 /* Select bsyflag depending on Bank */
1207 if(Bank == FLASH_BANK_1)
1208 {
1209 bsyflag = FLASH_FLAG_CRC_BUSY_BANK1;
1210 }
1211 else
1212 {
1213 bsyflag = FLASH_FLAG_CRC_BUSY_BANK2;
1214 }
1215
1216 /* Wait for the FLASH CRC computation to complete by polling on CRC_BUSY flag to be reset */
1217 while(__HAL_FLASH_GET_FLAG(bsyflag))
1218 {
1219 if(Timeout != HAL_MAX_DELAY)
1220 {
1221 if(((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1222 {
1223 return HAL_TIMEOUT;
1224 }
1225 }
1226 }
1227
1228 /* Check FLASH CRC read error flag */
1229 if(Bank == FLASH_BANK_1)
1230 {
1232 {
1233 /* Save the error code */
1235
1236 /* Clear FLASH CRC read error pending bit */
1238
1239 return HAL_ERROR;
1240 }
1241 }
1242#if defined (DUAL_BANK)
1243 else
1244 {
1246 {
1247 /* Save the error code */
1249
1250 /* Clear FLASH CRC read error pending bit */
1252
1253 return HAL_ERROR;
1254 }
1255 }
1256#endif /* DUAL_BANK */
1257
1258 /* If there is no error flag set */
1259 return HAL_OK;
1260}
1261
1262/**
1263 * @}
1264 */
1265
1266#endif /* HAL_FLASH_MODULE_ENABLED */
1267
1268/**
1269 * @}
1270 */
1271
1272/**
1273 * @}
1274 */
1275
1276
#define __IO
Defines 'read / write' permissions.
int32_t temp
Definition flight_e2e.c:78
#define __DSB()
Data Synchronization Barrier.
#define __ISB()
Instruction Synchronization Barrier.
#define CLEAR_BIT(REG, BIT)
Definition stm32h7xx.h:209
#define SET_BIT(REG, BIT)
Definition stm32h7xx.h:207
#define WRITE_REG(REG, VAL)
Definition stm32h7xx.h:215
#define READ_BIT(REG, BIT)
Definition stm32h7xx.h:211
@ RESET
Definition stm32h7xx.h:182
#define FLASH_BANK_1
Bank 1.
void FLASH_Erase_Sector(uint32_t Sector, uint32_t Banks, uint32_t VoltageRange)
#define HAL_FLASH_ERROR_OB_CHANGE
Option Byte Change Error.
#define HAL_FLASH_ERROR_CRCRD_BANK1
CRC Read Error on Bank1.
#define HAL_FLASH_ERROR_CRCRD_BANK2
CRC Read Error on Bank2.
#define HAL_FLASH_ERROR_NONE
No error.
void HAL_FLASH_IRQHandler(void)
void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue)
void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue)
HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress)
HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress)
HAL_StatusTypeDef HAL_FLASH_OB_Launch(void)
HAL_StatusTypeDef HAL_FLASH_Unlock(void)
HAL_StatusTypeDef HAL_FLASH_OB_Lock(void)
HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void)
HAL_StatusTypeDef HAL_FLASH_Lock(void)
uint32_t HAL_FLASH_GetError(void)
#define __HAL_FLASH_ENABLE_IT_BANK1(__INTERRUPT__)
Enable the specified FLASH interrupt.
#define __HAL_FLASH_ENABLE_IT_BANK2(__INTERRUPT__)
#define __HAL_FLASH_GET_FLAG_BANK1(__FLAG__)
Checks whether the specified FLASH flag is set or not.
#define __HAL_FLASH_GET_FLAG(__FLAG__)
#define __HAL_FLASH_DISABLE_IT_BANK2(__INTERRUPT__)
#define __HAL_FLASH_CLEAR_FLAG(__FLAG__)
#define __HAL_FLASH_CLEAR_FLAG_BANK2(__FLAG__)
#define __HAL_FLASH_GET_FLAG_BANK2(__FLAG__)
#define __HAL_FLASH_DISABLE_IT_BANK1(__INTERRUPT__)
Disable the specified FLASH interrupt.
#define __HAL_FLASH_CLEAR_FLAG_BANK1(__FLAG__)
Clear the specified FLASH flag.
FLASH_ProcedureTypeDef
FLASH Procedure structure definition.
@ FLASH_PROC_MASSERASE_BANK2
@ FLASH_PROC_PROGRAM_BANK1
@ FLASH_PROC_PROGRAM_BANK2
@ FLASH_PROC_NONE
@ FLASH_PROC_MASSERASE_BANK1
@ FLASH_PROC_SECTERASE_BANK2
@ FLASH_PROC_SECTERASE_BANK1
@ FLASH_PROC_ALLBANK_MASSERASE
#define FLASH_FLAG_DBECCERR_BANK1
Double Detection ECC Error on Bank 1 flag.
#define FLASH_FLAG_QW_BANK1
Wait Queue on Bank 1 flag.
#define FLASH_FLAG_CRCRDERR_BANK2
CRC Read error on Bank 2 flag.
#define FLASH_FLAG_DBECCERR_BANK2
Double Detection ECC Error on Bank 2 flag.
#define FLASH_FLAG_CRC_BUSY_BANK2
CRC Busy on Bank 2 flag.
#define FLASH_FLAG_INCERR_BANK2
Inconsistency Error on Bank 2 flag.
#define FLASH_FLAG_STRBERR_BANK1
Strobe Error on Bank 1 flag.
#define FLASH_FLAG_CRCRDERR_BANK1
CRC Read error on Bank 1 flag.
#define FLASH_FLAG_ALL_ERRORS_BANK2
All Bank 2 error flags.
#define FLASH_FLAG_QW_BANK2
Wait Queue on Bank 2 flag.
#define FLASH_FLAG_EOP_BANK1
End Of Program on Bank 1 flag.
#define FLASH_FLAG_SNECCERR_BANK2
Single ECC Error Correction on Bank 2 flag.
#define FLASH_FLAG_EOP_BANK2
End Of Program on Bank 2 flag.
#define FLASH_FLAG_PGSERR_BANK1
Program Sequence Error on Bank 1 flag.
#define FLASH_FLAG_WRPERR_BANK2
Write Protection Error on Bank 2 flag.
#define FLASH_FLAG_SNECCERR_BANK1
Single ECC Error Correction on Bank 1 flag.
#define FLASH_FLAG_STRBERR_BANK2
Strobe Error on Bank 2 flag.
#define FLASH_FLAG_ALL_ERRORS_BANK1
All Bank 1 error flags.
#define FLASH_FLAG_WRPERR_BANK1
Write Protection Error on Bank 1 flag.
#define FLASH_FLAG_PGSERR_BANK2
Program Sequence Error on Bank 2 flag.
#define FLASH_FLAG_CRC_BUSY_BANK1
CRC Busy on Bank 1 flag.
#define FLASH_FLAG_INCERR_BANK1
Inconsistency Error on Bank 1 flag.
#define FLASH_IT_WRPERR_BANK1
Write Protection Error on Bank 1 Interrupt source.
#define FLASH_IT_WRPERR_BANK2
Write Protection Error on Bank 2 Interrupt source.
#define FLASH_IT_EOP_BANK1
End of FLASH Bank 1 Operation Interrupt source.
#define FLASH_IT_STRBERR_BANK1
Strobe Error on Bank 1 Interrupt source.
#define FLASH_IT_INCERR_BANK2
Inconsistency Error on Bank 2 Interrupt source.
#define FLASH_IT_PGSERR_BANK1
Program Sequence Error on Bank 1 Interrupt source.
#define FLASH_IT_EOP_BANK2
End of FLASH Bank 2 Operation Interrupt source.
#define FLASH_IT_INCERR_BANK1
Inconsistency Error on Bank 1 Interrupt source.
#define FLASH_IT_STRBERR_BANK2
Strobe Error on Bank 2 Interrupt source.
#define FLASH_IT_PGSERR_BANK2
Program Sequence Error on Bank 2 Interrupt source.
#define FLASH_OPT_KEY2
#define FLASH_OPT_KEY1
#define FLASH_KEY2
#define FLASH_KEY1
HAL_StatusTypeDef FLASH_CRC_WaitForLastOperation(uint32_t Timeout, uint32_t Bank)
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout, uint32_t Bank)
HAL_StatusTypeDef FLASH_OB_WaitForLastOperation(uint32_t Timeout)
#define IS_FLASH_PROGRAM_ADDRESS_BANK1(ADDRESS)
#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS)
#define IS_FLASH_TYPEPROGRAM(VALUE)
#define IS_FLASH_BANK_EXCLUSIVE(BANK)
FLASH_ProcessTypeDef pFlash
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
#define FLASH_NB_32BITWORD_IN_FLASHWORD
#define FLASH_CR_PG
Internal buffer control bit.
#define FLASH_OPTSR_OPT_BUSY
Option byte change ongoing flag.
#define FLASH_OPTCR_OPTLOCK
FLASH_OPTCR lock option configuration bit.
#define FLASH_OPTCR_OPTSTART
Option byte start change option configuration bit.
#define FLASH_OPTSR_OPTCHANGEERR
Option byte change error flag.
#define FLASH_OPTCCR_CLR_OPTCHANGEERR
OPTCHANGEERR reset bit.
#define FLASH_CR_LOCK
Configuration lock bit.
#define FLASH_SR_EOP
End-of-program flag.
#define FLASH
This file contains all the functions prototypes for the HAL module driver.
#define assert_param(expr)
Uncomment the line below to expanse the "assert_param" macro in the HAL drivers code.
HAL_StatusTypeDef
HAL Status structures definition.
@ HAL_TIMEOUT
@ HAL_ERROR
@ HAL_OK
#define __HAL_UNLOCK(__HANDLE__)
#define UNUSED(x)
#define HAL_MAX_DELAY
@ HAL_UNLOCKED
#define __HAL_LOCK(__HANDLE__)
FLASH handle Structure definition.