2 ******************************************************************************
3 * @file stm32f7xx_hal_flash.c
4 * @author MCD Application Team
7 * @brief FLASH HAL module driver.
8 * This file provides firmware functions to manage the following
9 * functionalities of the internal FLASH memory:
10 * + Program operations functions
11 * + Memory Control functions
12 * + Peripheral Errors functions
15 ==============================================================================
16 ##### FLASH peripheral features #####
17 ==============================================================================
19 [..] The Flash memory interface manages CPU AHB I-Code and D-Code accesses
20 to the Flash memory. It implements the erase and program Flash memory operations
21 and the read and write protection mechanisms.
23 [..] The Flash memory interface accelerates code execution with a system of instruction
24 prefetch and cache lines.
26 [..] The FLASH main features are:
27 (+) Flash memory read operations
28 (+) Flash memory program/erase operations
29 (+) Read / write protections
30 (+) Prefetch on I-Code
31 (+) 64 cache lines of 128 bits on I-Code
32 (+) 8 cache lines of 128 bits on D-Code
34 ##### How to use this driver #####
35 ==============================================================================
37 This driver provides functions and macros to configure and program the FLASH
38 memory of all STM32F7xx devices.
40 (#) FLASH Memory IO Programming functions:
41 (++) Lock and Unlock the FLASH interface using HAL_FLASH_Unlock() and
42 HAL_FLASH_Lock() functions
43 (++) Program functions: byte, half word, word and double word
44 (++) There Two modes of programming :
45 (+++) Polling mode using HAL_FLASH_Program() function
46 (+++) Interrupt mode using HAL_FLASH_Program_IT() function
48 (#) Interrupts and flags management functions :
49 (++) Handle FLASH interrupts by calling HAL_FLASH_IRQHandler()
50 (++) Wait for last FLASH operation according to its status
51 (++) Get error flag status by calling HAL_SetErrorCode()
53 In addition to these functions, this driver includes a set of macros allowing
54 to handle the following operations:
56 (+) Enable/Disable the prefetch buffer
57 (+) Enable/Disable the Instruction cache and the Data cache
58 (+) Reset the Instruction cache and the Data cache
59 (+) Enable/Disable the FLASH interrupts
60 (+) Monitor the FLASH flags status
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 (@) Any attempt to read the Flash memory while it is being written or erased, causes the
67 bus to stall. Read operations are processed correctly once the program operation has
68 completed. This means that code or data fetches cannot be performed while a write/erase
72 ******************************************************************************
75 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
77 * Redistribution and use in source and binary forms, with or without modification,
78 * are permitted provided that the following conditions are met:
79 * 1. Redistributions of source code must retain the above copyright notice,
80 * this list of conditions and the following disclaimer.
81 * 2. Redistributions in binary form must reproduce the above copyright notice,
82 * this list of conditions and the following disclaimer in the documentation
83 * and/or other materials provided with the distribution.
84 * 3. Neither the name of STMicroelectronics nor the names of its contributors
85 * may be used to endorse or promote products derived from this software
86 * without specific prior written permission.
88 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
89 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
90 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
91 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
92 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
93 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
94 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
95 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
96 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
97 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
99 ******************************************************************************
102 /* Includes ------------------------------------------------------------------*/
103 #include "stm32f7xx_hal.h"
105 /** @addtogroup STM32F7xx_HAL_Driver
109 /** @defgroup FLASH FLASH
110 * @brief FLASH HAL module driver
114 #ifdef HAL_FLASH_MODULE_ENABLED
116 /* Private typedef -----------------------------------------------------------*/
117 /* Private define ------------------------------------------------------------*/
118 /** @addtogroup FLASH_Private_Constants
121 #define SECTOR_MASK ((uint32_t)0xFFFFFF07U)
122 #define FLASH_TIMEOUT_VALUE ((uint32_t)50000U)/* 50 s */
126 /* Private macro -------------------------------------------------------------*/
127 /* Private variables ---------------------------------------------------------*/
128 /** @addtogroup FLASH_Private_Variables
131 /* Variable used for Erase sectors under interruption */
132 FLASH_ProcessTypeDef pFlash
;
137 /* Private function prototypes -----------------------------------------------*/
138 /** @addtogroup FLASH_Private_Functions
141 /* Program operations */
142 static void FLASH_Program_DoubleWord(uint32_t Address
, uint64_t Data
);
143 static void FLASH_Program_Word(uint32_t Address
, uint32_t Data
);
144 static void FLASH_Program_HalfWord(uint32_t Address
, uint16_t Data
);
145 static void FLASH_Program_Byte(uint32_t Address
, uint8_t Data
);
146 static void FLASH_SetErrorCode(void);
148 HAL_StatusTypeDef
FLASH_WaitForLastOperation(uint32_t Timeout
);
153 /* Exported functions --------------------------------------------------------*/
154 /** @defgroup FLASH_Exported_Functions FLASH Exported Functions
158 /** @defgroup FLASH_Exported_Functions_Group1 Programming operation functions
159 * @brief Programming operation functions
162 ===============================================================================
163 ##### Programming operation functions #####
164 ===============================================================================
166 This subsection provides a set of functions allowing to manage the FLASH
174 * @brief Program byte, halfword, word or double word at a specified address
175 * @param TypeProgram: Indicate the way to program at a specified address.
176 * This parameter can be a value of @ref FLASH_Type_Program
177 * @param Address: specifies the address to be programmed.
178 * @param Data: specifies the data to be programmed
180 * @retval HAL_StatusTypeDef HAL Status
182 HAL_StatusTypeDef
HAL_FLASH_Program(uint32_t TypeProgram
, uint32_t Address
, uint64_t Data
)
184 HAL_StatusTypeDef status
= HAL_ERROR
;
189 /* Check the parameters */
190 assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram
));
192 /* Wait for last operation to be completed */
193 status
= FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE
);
199 case FLASH_TYPEPROGRAM_BYTE
:
201 /*Program byte (8-bit) at a specified address.*/
202 FLASH_Program_Byte(Address
, (uint8_t) Data
);
206 case FLASH_TYPEPROGRAM_HALFWORD
:
208 /*Program halfword (16-bit) at a specified address.*/
209 FLASH_Program_HalfWord(Address
, (uint16_t) Data
);
213 case FLASH_TYPEPROGRAM_WORD
:
215 /*Program word (32-bit) at a specified address.*/
216 FLASH_Program_Word(Address
, (uint32_t) Data
);
220 case FLASH_TYPEPROGRAM_DOUBLEWORD
:
222 /*Program double word (64-bit) at a specified address.*/
223 FLASH_Program_DoubleWord(Address
, Data
);
229 /* Wait for last operation to be completed */
230 status
= FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE
);
232 /* If the program operation is completed, disable the PG Bit */
233 FLASH
->CR
&= (~FLASH_CR_PG
);
236 /* Process Unlocked */
237 __HAL_UNLOCK(&pFlash
);
243 * @brief Program byte, halfword, word or double word at a specified address with interrupt enabled.
244 * @param TypeProgram: Indicate the way to program at a specified address.
245 * This parameter can be a value of @ref FLASH_Type_Program
246 * @param Address: specifies the address to be programmed.
247 * @param Data: specifies the data to be programmed
251 HAL_StatusTypeDef
HAL_FLASH_Program_IT(uint32_t TypeProgram
, uint32_t Address
, uint64_t Data
)
253 HAL_StatusTypeDef status
= HAL_OK
;
258 /* Check the parameters */
259 assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram
));
261 /* Enable End of FLASH Operation interrupt */
262 __HAL_FLASH_ENABLE_IT(FLASH_IT_EOP
);
264 /* Enable Error source interrupt */
265 __HAL_FLASH_ENABLE_IT(FLASH_IT_ERR
);
267 /* Clear pending flags (if any) */
268 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP
| FLASH_FLAG_OPERR
| FLASH_FLAG_WRPERR
|\
269 FLASH_FLAG_PGAERR
| FLASH_FLAG_PGPERR
| FLASH_FLAG_ERSERR
);
271 pFlash
.ProcedureOnGoing
= FLASH_PROC_PROGRAM
;
272 pFlash
.Address
= Address
;
276 case FLASH_TYPEPROGRAM_BYTE
:
278 /*Program byte (8-bit) at a specified address.*/
279 FLASH_Program_Byte(Address
, (uint8_t) Data
);
283 case FLASH_TYPEPROGRAM_HALFWORD
:
285 /*Program halfword (16-bit) at a specified address.*/
286 FLASH_Program_HalfWord(Address
, (uint16_t) Data
);
290 case FLASH_TYPEPROGRAM_WORD
:
292 /*Program word (32-bit) at a specified address.*/
293 FLASH_Program_Word(Address
, (uint32_t) Data
);
297 case FLASH_TYPEPROGRAM_DOUBLEWORD
:
299 /*Program double word (64-bit) at a specified address.*/
300 FLASH_Program_DoubleWord(Address
, Data
);
310 * @brief This function handles FLASH interrupt request.
313 void HAL_FLASH_IRQHandler(void)
317 /* If the program operation is completed, disable the PG Bit */
318 FLASH
->CR
&= (~FLASH_CR_PG
);
320 /* If the erase operation is completed, disable the SER Bit */
321 FLASH
->CR
&= (~FLASH_CR_SER
);
322 FLASH
->CR
&= SECTOR_MASK
;
324 /* if the erase operation is completed, disable the MER Bit */
325 FLASH
->CR
&= (~FLASH_MER_BIT
);
327 /* Check FLASH End of Operation flag */
328 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP
) != RESET
)
330 /* Clear FLASH End of Operation pending bit */
331 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP
);
333 switch (pFlash
.ProcedureOnGoing
)
335 case FLASH_PROC_SECTERASE
:
337 /* Nb of sector to erased can be decreased */
338 pFlash
.NbSectorsToErase
--;
340 /* Check if there are still sectors to erase */
341 if(pFlash
.NbSectorsToErase
!= 0)
343 temp
= pFlash
.Sector
;
344 /* Indicate user which sector has been erased */
345 HAL_FLASH_EndOfOperationCallback(temp
);
347 /* Increment sector number */
348 temp
= ++pFlash
.Sector
;
349 FLASH_Erase_Sector(temp
, pFlash
.VoltageForErase
);
353 /* No more sectors to Erase, user callback can be called.*/
354 /* Reset Sector and stop Erase sectors procedure */
355 pFlash
.Sector
= temp
= 0xFFFFFFFFU
;
356 /* FLASH EOP interrupt user callback */
357 HAL_FLASH_EndOfOperationCallback(temp
);
358 /* Sector Erase procedure is completed */
359 pFlash
.ProcedureOnGoing
= FLASH_PROC_NONE
;
364 case FLASH_PROC_MASSERASE
:
366 /* MassErase ended. Return the selected bank : in this product we don't have Banks */
367 /* FLASH EOP interrupt user callback */
368 HAL_FLASH_EndOfOperationCallback(0);
369 /* MAss Erase procedure is completed */
370 pFlash
.ProcedureOnGoing
= FLASH_PROC_NONE
;
374 case FLASH_PROC_PROGRAM
:
376 /*Program ended. Return the selected address*/
377 /* FLASH EOP interrupt user callback */
378 HAL_FLASH_EndOfOperationCallback(pFlash
.Address
);
379 /* Programming procedure is completed */
380 pFlash
.ProcedureOnGoing
= FLASH_PROC_NONE
;
388 /* Check FLASH operation error flags */
389 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_ALL_ERRORS
) != RESET
)
391 switch (pFlash
.ProcedureOnGoing
)
393 case FLASH_PROC_SECTERASE
:
395 /* return the faulty sector */
396 temp
= pFlash
.Sector
;
397 pFlash
.Sector
= 0xFFFFFFFFU
;
400 case FLASH_PROC_MASSERASE
:
402 /* No return in case of Mass Erase */
406 case FLASH_PROC_PROGRAM
:
408 /*return the faulty address*/
409 temp
= pFlash
.Address
;
415 /*Save the Error code*/
416 FLASH_SetErrorCode();
418 /* FLASH error interrupt user callback */
419 HAL_FLASH_OperationErrorCallback(temp
);
421 /*Stop the procedure ongoing */
422 pFlash
.ProcedureOnGoing
= FLASH_PROC_NONE
;
425 if(pFlash
.ProcedureOnGoing
== FLASH_PROC_NONE
)
427 /* Disable End of FLASH Operation interrupt */
428 __HAL_FLASH_DISABLE_IT(FLASH_IT_EOP
);
430 /* Disable Error source interrupt */
431 __HAL_FLASH_DISABLE_IT(FLASH_IT_ERR
);
433 /* Process Unlocked */
434 __HAL_UNLOCK(&pFlash
);
440 * @brief FLASH end of operation interrupt callback
441 * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure
442 * - Sectors Erase: Sector which has been erased (if 0xFFFFFFFF, it means that
443 * all the selected sectors have been erased)
444 * - Program : Address which was selected for data program
445 * - Mass Erase : No return value expected
448 __weak
void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue
)
450 /* Prevent unused argument(s) compilation warning */
452 /* NOTE : This function Should not be modified, when the callback is needed,
453 the HAL_FLASH_EndOfOperationCallback could be implemented in the user file
458 * @brief FLASH operation error interrupt callback
459 * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure
460 * - Sectors Erase: Sector which has been erased (if 0xFFFFFFFF, it means that
461 * all the selected sectors have been erased)
462 * - Program : Address which was selected for data program
463 * - Mass Erase : No return value expected
466 __weak
void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue
)
468 /* Prevent unused argument(s) compilation warning */
470 /* NOTE : This function Should not be modified, when the callback is needed,
471 the HAL_FLASH_OperationErrorCallback could be implemented in the user file
479 /** @defgroup FLASH_Exported_Functions_Group2 Peripheral Control functions
480 * @brief management functions
483 ===============================================================================
484 ##### Peripheral Control functions #####
485 ===============================================================================
487 This subsection provides a set of functions allowing to control the FLASH
495 * @brief Unlock the FLASH control register access
498 HAL_StatusTypeDef
HAL_FLASH_Unlock(void)
500 if((FLASH
->CR
& FLASH_CR_LOCK
) != RESET
)
502 /* Authorize the FLASH Registers access */
503 FLASH
->KEYR
= FLASH_KEY1
;
504 FLASH
->KEYR
= FLASH_KEY2
;
515 * @brief Locks the FLASH control register access
518 HAL_StatusTypeDef
HAL_FLASH_Lock(void)
520 /* Set the LOCK Bit to lock the FLASH Registers access */
521 FLASH
->CR
|= FLASH_CR_LOCK
;
527 * @brief Unlock the FLASH Option Control Registers access.
530 HAL_StatusTypeDef
HAL_FLASH_OB_Unlock(void)
532 if((FLASH
->OPTCR
& FLASH_OPTCR_OPTLOCK
) != RESET
)
534 /* Authorizes the Option Byte register programming */
535 FLASH
->OPTKEYR
= FLASH_OPT_KEY1
;
536 FLASH
->OPTKEYR
= FLASH_OPT_KEY2
;
547 * @brief Lock the FLASH Option Control Registers access.
550 HAL_StatusTypeDef
HAL_FLASH_OB_Lock(void)
552 /* Set the OPTLOCK Bit to lock the FLASH Option Byte Registers access */
553 FLASH
->OPTCR
|= FLASH_OPTCR_OPTLOCK
;
559 * @brief Launch the option byte loading.
562 HAL_StatusTypeDef
HAL_FLASH_OB_Launch(void)
564 /* Set the OPTSTRT bit in OPTCR register */
565 FLASH
->OPTCR
|= FLASH_OPTCR_OPTSTRT
;
567 /* Wait for last operation to be completed */
568 return(FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE
));
575 /** @defgroup FLASH_Exported_Functions_Group3 Peripheral State and Errors functions
576 * @brief Peripheral Errors functions
579 ===============================================================================
580 ##### Peripheral Errors functions #####
581 ===============================================================================
583 This subsection permits to get in run-time Errors of the FLASH peripheral.
590 * @brief Get the specific FLASH error flag.
591 * @retval FLASH_ErrorCode: The returned value can be:
592 * @arg FLASH_ERROR_ERS: FLASH Erasing Sequence error flag
593 * @arg FLASH_ERROR_PGP: FLASH Programming Parallelism error flag
594 * @arg FLASH_ERROR_PGA: FLASH Programming Alignment error flag
595 * @arg FLASH_ERROR_WRP: FLASH Write protected error flag
596 * @arg FLASH_ERROR_OPERATION: FLASH operation Error flag
598 uint32_t HAL_FLASH_GetError(void)
600 return pFlash
.ErrorCode
;
608 * @brief Wait for a FLASH operation to complete.
609 * @param Timeout: maximum flash operationtimeout
612 HAL_StatusTypeDef
FLASH_WaitForLastOperation(uint32_t Timeout
)
614 uint32_t tickstart
= 0;
616 /* Clear Error Code */
617 pFlash
.ErrorCode
= HAL_FLASH_ERROR_NONE
;
619 /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
620 Even if the FLASH operation fails, the BUSY flag will be reset and an error
623 tickstart
= HAL_GetTick();
625 while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY
) != RESET
)
627 if(Timeout
!= HAL_MAX_DELAY
)
629 if((Timeout
== 0)||((HAL_GetTick() - tickstart
) > Timeout
))
636 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_ALL_ERRORS
) != RESET
)
638 /*Save the error code*/
639 FLASH_SetErrorCode();
643 /* Check FLASH End of Operation flag */
644 if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP
) != RESET
)
646 /* Clear FLASH End of Operation pending bit */
647 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP
);
650 /* If there is an error flag set */
656 * @brief Program a double word (64-bit) at a specified address.
657 * @note This function must be used when the device voltage range is from
658 * 2.7V to 3.6V and an External Vpp is present.
660 * @note If an erase and a program operations are requested simultaneously,
661 * the erase operation is performed before the program one.
663 * @param Address: specifies the address to be programmed.
664 * @param Data: specifies the data to be programmed.
667 static void FLASH_Program_DoubleWord(uint32_t Address
, uint64_t Data
)
669 /* Check the parameters */
670 assert_param(IS_FLASH_ADDRESS(Address
));
672 /* If the previous operation is completed, proceed to program the new data */
673 FLASH
->CR
&= CR_PSIZE_MASK
;
674 FLASH
->CR
|= FLASH_PSIZE_DOUBLE_WORD
;
675 FLASH
->CR
|= FLASH_CR_PG
;
677 *(__IO
uint64_t*)Address
= Data
;
679 /* Data synchronous Barrier (DSB) Just after the write operation
680 This will force the CPU to respect the sequence of instruction (no optimization).*/
686 * @brief Program word (32-bit) at a specified address.
687 * @note This function must be used when the device voltage range is from
690 * @note If an erase and a program operations are requested simultaneously,
691 * the erase operation is performed before the program one.
693 * @param Address: specifies the address to be programmed.
694 * @param Data: specifies the data to be programmed.
697 static void FLASH_Program_Word(uint32_t Address
, uint32_t Data
)
699 /* Check the parameters */
700 assert_param(IS_FLASH_ADDRESS(Address
));
702 /* If the previous operation is completed, proceed to program the new data */
703 FLASH
->CR
&= CR_PSIZE_MASK
;
704 FLASH
->CR
|= FLASH_PSIZE_WORD
;
705 FLASH
->CR
|= FLASH_CR_PG
;
707 *(__IO
uint32_t*)Address
= Data
;
709 /* Data synchronous Barrier (DSB) Just after the write operation
710 This will force the CPU to respect the sequence of instruction (no optimization).*/
715 * @brief Program a half-word (16-bit) at a specified address.
716 * @note This function must be used when the device voltage range is from
719 * @note If an erase and a program operations are requested simultaneously,
720 * the erase operation is performed before the program one.
722 * @param Address: specifies the address to be programmed.
723 * @param Data: specifies the data to be programmed.
726 static void FLASH_Program_HalfWord(uint32_t Address
, uint16_t Data
)
728 /* Check the parameters */
729 assert_param(IS_FLASH_ADDRESS(Address
));
731 /* If the previous operation is completed, proceed to program the new data */
732 FLASH
->CR
&= CR_PSIZE_MASK
;
733 FLASH
->CR
|= FLASH_PSIZE_HALF_WORD
;
734 FLASH
->CR
|= FLASH_CR_PG
;
736 *(__IO
uint16_t*)Address
= Data
;
738 /* Data synchronous Barrier (DSB) Just after the write operation
739 This will force the CPU to respect the sequence of instruction (no optimization).*/
745 * @brief Program byte (8-bit) at a specified address.
746 * @note This function must be used when the device voltage range is from
749 * @note If an erase and a program operations are requested simultaneously,
750 * the erase operation is performed before the program one.
752 * @param Address: specifies the address to be programmed.
753 * @param Data: specifies the data to be programmed.
756 static void FLASH_Program_Byte(uint32_t Address
, uint8_t Data
)
758 /* Check the parameters */
759 assert_param(IS_FLASH_ADDRESS(Address
));
761 /* If the previous operation is completed, proceed to program the new data */
762 FLASH
->CR
&= CR_PSIZE_MASK
;
763 FLASH
->CR
|= FLASH_PSIZE_BYTE
;
764 FLASH
->CR
|= FLASH_CR_PG
;
766 *(__IO
uint8_t*)Address
= Data
;
768 /* Data synchronous Barrier (DSB) Just after the write operation
769 This will force the CPU to respect the sequence of instruction (no optimization).*/
774 * @brief Set the specific FLASH error flag.
777 static void FLASH_SetErrorCode(void)
779 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR
) != RESET
)
781 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_OPERATION
;
784 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR
) != RESET
)
786 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_WRP
;
789 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR
) != RESET
)
791 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_PGA
;
794 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGPERR
) != RESET
)
796 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_PGP
;
799 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_ERSERR
) != RESET
)
801 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_ERS
;
804 #if defined (FLASH_OPTCR2_PCROP)
805 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR
) != RESET
)
807 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_RD
;
809 #endif /* FLASH_OPTCR2_PCROP */
811 /* Clear error programming flags */
812 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS
);
819 #endif /* HAL_FLASH_MODULE_ENABLED */
829 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/