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) 2016 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 switch (pFlash
.ProcedureOnGoing
)
332 case FLASH_PROC_SECTERASE
:
334 /* Nb of sector to erased can be decreased */
335 pFlash
.NbSectorsToErase
--;
337 /* Check if there are still sectors to erase */
338 if(pFlash
.NbSectorsToErase
!= 0)
340 temp
= pFlash
.Sector
;
341 /* Indicate user which sector has been erased */
342 HAL_FLASH_EndOfOperationCallback(temp
);
344 /* Clear pending flags (if any) */
345 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP
);
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
;
360 /* Clear FLASH End of Operation pending bit */
361 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP
);
366 case FLASH_PROC_MASSERASE
:
368 /* MassErase ended. Return the selected bank : in this product we don't have Banks */
369 /* FLASH EOP interrupt user callback */
370 HAL_FLASH_EndOfOperationCallback(0);
371 /* MAss Erase procedure is completed */
372 pFlash
.ProcedureOnGoing
= FLASH_PROC_NONE
;
373 /* Clear FLASH End of Operation pending bit */
374 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP
);
378 case FLASH_PROC_PROGRAM
:
380 /*Program ended. Return the selected address*/
381 /* FLASH EOP interrupt user callback */
382 HAL_FLASH_EndOfOperationCallback(pFlash
.Address
);
383 /* Programming procedure is completed */
384 pFlash
.ProcedureOnGoing
= FLASH_PROC_NONE
;
385 /* Clear FLASH End of Operation pending bit */
386 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP
);
394 /* Check FLASH operation error flags */
395 if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR
| FLASH_FLAG_WRPERR
| FLASH_FLAG_PGAERR
| FLASH_FLAG_PGPERR
| FLASH_FLAG_ERSERR
)) != RESET
)
397 switch (pFlash
.ProcedureOnGoing
)
399 case FLASH_PROC_SECTERASE
:
401 /* return the faulty sector */
402 temp
= pFlash
.Sector
;
403 pFlash
.Sector
= 0xFFFFFFFFU
;
406 case FLASH_PROC_MASSERASE
:
408 /* No return in case of Mass Erase */
412 case FLASH_PROC_PROGRAM
:
414 /*return the faulty address*/
415 temp
= pFlash
.Address
;
421 /*Save the Error code*/
422 FLASH_SetErrorCode();
424 /* FLASH error interrupt user callback */
425 HAL_FLASH_OperationErrorCallback(temp
);
426 /* Clear FLASH error pending bits */
427 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR
| FLASH_FLAG_WRPERR
| FLASH_FLAG_PGAERR
| FLASH_FLAG_PGPERR
| FLASH_FLAG_ERSERR
);
429 /*Stop the procedure ongoing */
430 pFlash
.ProcedureOnGoing
= FLASH_PROC_NONE
;
433 if(pFlash
.ProcedureOnGoing
== FLASH_PROC_NONE
)
435 /* Disable End of FLASH Operation interrupt */
436 __HAL_FLASH_DISABLE_IT(FLASH_IT_EOP
);
438 /* Disable Error source interrupt */
439 __HAL_FLASH_DISABLE_IT(FLASH_IT_ERR
);
441 /* Process Unlocked */
442 __HAL_UNLOCK(&pFlash
);
448 * @brief FLASH end of operation interrupt callback
449 * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure
450 * - Sectors Erase: Sector which has been erased (if 0xFFFFFFFF, it means that
451 * all the selected sectors have been erased)
452 * - Program : Address which was selected for data program
453 * - Mass Erase : No return value expected
456 __weak
void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue
)
458 /* Prevent unused argument(s) compilation warning */
460 /* NOTE : This function Should not be modified, when the callback is needed,
461 the HAL_FLASH_EndOfOperationCallback could be implemented in the user file
466 * @brief FLASH operation error interrupt callback
467 * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure
468 * - Sectors Erase: Sector which has been erased (if 0xFFFFFFFF, it means that
469 * all the selected sectors have been erased)
470 * - Program : Address which was selected for data program
471 * - Mass Erase : No return value expected
474 __weak
void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue
)
476 /* Prevent unused argument(s) compilation warning */
478 /* NOTE : This function Should not be modified, when the callback is needed,
479 the HAL_FLASH_OperationErrorCallback could be implemented in the user file
487 /** @defgroup FLASH_Exported_Functions_Group2 Peripheral Control functions
488 * @brief management functions
491 ===============================================================================
492 ##### Peripheral Control functions #####
493 ===============================================================================
495 This subsection provides a set of functions allowing to control the FLASH
503 * @brief Unlock the FLASH control register access
506 HAL_StatusTypeDef
HAL_FLASH_Unlock(void)
508 if((FLASH
->CR
& FLASH_CR_LOCK
) != RESET
)
510 /* Authorize the FLASH Registers access */
511 FLASH
->KEYR
= FLASH_KEY1
;
512 FLASH
->KEYR
= FLASH_KEY2
;
523 * @brief Locks the FLASH control register access
526 HAL_StatusTypeDef
HAL_FLASH_Lock(void)
528 /* Set the LOCK Bit to lock the FLASH Registers access */
529 FLASH
->CR
|= FLASH_CR_LOCK
;
535 * @brief Unlock the FLASH Option Control Registers access.
538 HAL_StatusTypeDef
HAL_FLASH_OB_Unlock(void)
540 if((FLASH
->OPTCR
& FLASH_OPTCR_OPTLOCK
) != RESET
)
542 /* Authorizes the Option Byte register programming */
543 FLASH
->OPTKEYR
= FLASH_OPT_KEY1
;
544 FLASH
->OPTKEYR
= FLASH_OPT_KEY2
;
555 * @brief Lock the FLASH Option Control Registers access.
558 HAL_StatusTypeDef
HAL_FLASH_OB_Lock(void)
560 /* Set the OPTLOCK Bit to lock the FLASH Option Byte Registers access */
561 FLASH
->OPTCR
|= FLASH_OPTCR_OPTLOCK
;
567 * @brief Launch the option byte loading.
570 HAL_StatusTypeDef
HAL_FLASH_OB_Launch(void)
572 /* Set the OPTSTRT bit in OPTCR register */
573 FLASH
->OPTCR
|= FLASH_OPTCR_OPTSTRT
;
575 /* Wait for last operation to be completed */
576 return(FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE
));
583 /** @defgroup FLASH_Exported_Functions_Group3 Peripheral State and Errors functions
584 * @brief Peripheral Errors functions
587 ===============================================================================
588 ##### Peripheral Errors functions #####
589 ===============================================================================
591 This subsection permits to get in run-time Errors of the FLASH peripheral.
598 * @brief Get the specific FLASH error flag.
599 * @retval FLASH_ErrorCode: The returned value can be:
600 * @arg FLASH_ERROR_ERS: FLASH Erasing Sequence error flag
601 * @arg FLASH_ERROR_PGP: FLASH Programming Parallelism error flag
602 * @arg FLASH_ERROR_PGA: FLASH Programming Alignment error flag
603 * @arg FLASH_ERROR_WRP: FLASH Write protected error flag
604 * @arg FLASH_ERROR_OPERATION: FLASH operation Error flag
606 uint32_t HAL_FLASH_GetError(void)
608 return pFlash
.ErrorCode
;
616 * @brief Wait for a FLASH operation to complete.
617 * @param Timeout: maximum flash operationtimeout
620 HAL_StatusTypeDef
FLASH_WaitForLastOperation(uint32_t Timeout
)
622 uint32_t tickstart
= 0;
624 /* Clear Error Code */
625 pFlash
.ErrorCode
= HAL_FLASH_ERROR_NONE
;
627 /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
628 Even if the FLASH operation fails, the BUSY flag will be reset and an error
631 tickstart
= HAL_GetTick();
633 while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY
) != RESET
)
635 if(Timeout
!= HAL_MAX_DELAY
)
637 if((Timeout
== 0)||((HAL_GetTick() - tickstart
) > Timeout
))
644 if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR
| FLASH_FLAG_WRPERR
| FLASH_FLAG_PGAERR
| \
645 FLASH_FLAG_PGPERR
| FLASH_FLAG_ERSERR
)) != RESET
)
647 /*Save the error code*/
648 FLASH_SetErrorCode();
652 /* If there is an error flag set */
658 * @brief Program a double word (64-bit) at a specified address.
659 * @note This function must be used when the device voltage range is from
660 * 2.7V to 3.6V and an External Vpp is present.
662 * @note If an erase and a program operations are requested simultaneously,
663 * the erase operation is performed before the program one.
665 * @param Address: specifies the address to be programmed.
666 * @param Data: specifies the data to be programmed.
669 static void FLASH_Program_DoubleWord(uint32_t Address
, uint64_t Data
)
671 /* Check the parameters */
672 assert_param(IS_FLASH_ADDRESS(Address
));
674 /* If the previous operation is completed, proceed to program the new data */
675 FLASH
->CR
&= CR_PSIZE_MASK
;
676 FLASH
->CR
|= FLASH_PSIZE_DOUBLE_WORD
;
677 FLASH
->CR
|= FLASH_CR_PG
;
679 *(__IO
uint64_t*)Address
= Data
;
681 /* Data synchronous Barrier (DSB) Just after the write operation
682 This will force the CPU to respect the sequence of instruction (no optimization).*/
688 * @brief Program word (32-bit) at a specified address.
689 * @note This function must be used when the device voltage range is from
692 * @note If an erase and a program operations are requested simultaneously,
693 * the erase operation is performed before the program one.
695 * @param Address: specifies the address to be programmed.
696 * @param Data: specifies the data to be programmed.
699 static void FLASH_Program_Word(uint32_t Address
, uint32_t Data
)
701 /* Check the parameters */
702 assert_param(IS_FLASH_ADDRESS(Address
));
704 /* If the previous operation is completed, proceed to program the new data */
705 FLASH
->CR
&= CR_PSIZE_MASK
;
706 FLASH
->CR
|= FLASH_PSIZE_WORD
;
707 FLASH
->CR
|= FLASH_CR_PG
;
709 *(__IO
uint32_t*)Address
= Data
;
711 /* Data synchronous Barrier (DSB) Just after the write operation
712 This will force the CPU to respect the sequence of instruction (no optimization).*/
717 * @brief Program a half-word (16-bit) at a specified address.
718 * @note This function must be used when the device voltage range is from
721 * @note If an erase and a program operations are requested simultaneously,
722 * the erase operation is performed before the program one.
724 * @param Address: specifies the address to be programmed.
725 * @param Data: specifies the data to be programmed.
728 static void FLASH_Program_HalfWord(uint32_t Address
, uint16_t Data
)
730 /* Check the parameters */
731 assert_param(IS_FLASH_ADDRESS(Address
));
733 /* If the previous operation is completed, proceed to program the new data */
734 FLASH
->CR
&= CR_PSIZE_MASK
;
735 FLASH
->CR
|= FLASH_PSIZE_HALF_WORD
;
736 FLASH
->CR
|= FLASH_CR_PG
;
738 *(__IO
uint16_t*)Address
= Data
;
740 /* Data synchronous Barrier (DSB) Just after the write operation
741 This will force the CPU to respect the sequence of instruction (no optimization).*/
747 * @brief Program byte (8-bit) at a specified address.
748 * @note This function must be used when the device voltage range is from
751 * @note If an erase and a program operations are requested simultaneously,
752 * the erase operation is performed before the program one.
754 * @param Address: specifies the address to be programmed.
755 * @param Data: specifies the data to be programmed.
758 static void FLASH_Program_Byte(uint32_t Address
, uint8_t Data
)
760 /* Check the parameters */
761 assert_param(IS_FLASH_ADDRESS(Address
));
763 /* If the previous operation is completed, proceed to program the new data */
764 FLASH
->CR
&= CR_PSIZE_MASK
;
765 FLASH
->CR
|= FLASH_PSIZE_BYTE
;
766 FLASH
->CR
|= FLASH_CR_PG
;
768 *(__IO
uint8_t*)Address
= Data
;
770 /* Data synchronous Barrier (DSB) Just after the write operation
771 This will force the CPU to respect the sequence of instruction (no optimization).*/
776 * @brief Set the specific FLASH error flag.
779 static void FLASH_SetErrorCode(void)
781 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR
) != RESET
)
783 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_WRP
;
786 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR
) != RESET
)
788 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_PGA
;
791 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGPERR
) != RESET
)
793 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_PGP
;
796 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_ERSERR
) != RESET
)
798 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_ERS
;
801 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR
) != RESET
)
803 pFlash
.ErrorCode
|= HAL_FLASH_ERROR_OPERATION
;
811 #endif /* HAL_FLASH_MODULE_ENABLED */
821 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/