98#ifdef HAL_FLASH_MODULE_ENABLED
105#define FLASH_TIMEOUT_VALUE 50000U
115 .NbSectorsToErase = 0U,
116 .VoltageForErase= 0U,
163 __IO uint32_t *dest_addr = (
__IO uint32_t *)FlashAddress;
164 __IO uint32_t *src_addr = (
__IO uint32_t*)DataAddress;
175#if defined (FLASH_OPTCR_PG_OTP)
185#if defined (DUAL_BANK)
186 else if(IS_FLASH_PROGRAM_ADDRESS_BANK2(FlashAddress))
204#if defined (DUAL_BANK)
207#if defined (FLASH_OPTCR_PG_OTP)
208 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
226#if defined (FLASH_OPTCR_PG_OTP)
227 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
243#if defined (FLASH_OPTCR_PG_OTP)
244 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
247 *(
__IO uint16_t *)FlashAddress = *(
__IO uint16_t*)DataAddress;
255 *dest_addr = *src_addr;
259 }
while (row_index != 0U);
268#if defined (DUAL_BANK)
269#if defined (FLASH_OPTCR_PG_OTP)
270 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
290#if defined (FLASH_OPTCR_PG_OTP)
291 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
328 __IO uint32_t *dest_addr = (
__IO uint32_t*)FlashAddress;
329 __IO uint32_t *src_addr = (
__IO uint32_t*)DataAddress;
343#if defined (FLASH_OPTCR_PG_OTP)
353#if defined (DUAL_BANK)
354 else if(IS_FLASH_PROGRAM_ADDRESS_BANK2(FlashAddress))
374 pFlash.Address = FlashAddress;
376#if defined (DUAL_BANK)
382#if defined (FLASH_OPTCR_PG_OTP)
383 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
396#if defined (FLASH_CR_OPERRIE)
413#if defined (FLASH_CR_OPERRIE)
425#if defined (FLASH_OPTCR_PG_OTP)
426 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
439#if defined (FLASH_CR_OPERRIE)
451#if defined (FLASH_OPTCR_PG_OTP)
452 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
455 *(
__IO uint16_t *)FlashAddress = *(
__IO uint16_t*)DataAddress;
463 *dest_addr = *src_addr;
467 }
while (row_index != 0U);
493 pFlash.NbSectorsToErase--;
496 if(
pFlash.NbSectorsToErase != 0U)
513 pFlash.Sector = 0xFFFFFFFFU;
525 procedure =
pFlash.ProcedureOnGoing;
555#if defined (DUAL_BANK)
562 pFlash.NbSectorsToErase--;
565 if(
pFlash.NbSectorsToErase != 0U)
582 pFlash.Sector = 0xFFFFFFFFU;
594 procedure =
pFlash.ProcedureOnGoing;
626#if defined (FLASH_SR_OPERR)
637 pFlash.ErrorCode |= errorflag;
642 procedure =
pFlash.ProcedureOnGoing;
648 pFlash.Sector = 0xFFFFFFFFU;
668#if (USE_FLASH_ECC == 1U)
675 pFlash.ErrorCode |= errorflag;
678 HAL_FLASHEx_EccCorrectionCallback();
690 pFlash.ErrorCode |= errorflag;
693 HAL_FLASHEx_EccDetectionCallback();
700#if defined (DUAL_BANK)
702#if defined (FLASH_SR_OPERR)
713 pFlash.ErrorCode |= (errorflag | 0x80000000U);
718 procedure =
pFlash.ProcedureOnGoing;
724 pFlash.Sector = 0xFFFFFFFFU;
744#if (USE_FLASH_ECC == 1U)
751 pFlash.ErrorCode |= (errorflag | 0x80000000U);
754 HAL_FLASHEx_EccCorrectionCallback();
766 pFlash.ErrorCode |= (errorflag | 0x80000000U);
769 HAL_FLASHEx_EccDetectionCallback();
780#if defined (FLASH_CR_OPERRIE)
785#if defined (DUAL_BANK)
795#if defined (DUAL_BANK)
882#if defined (DUAL_BANK)
915#if defined (DUAL_BANK)
982#if defined (DUAL_BANK)
1083 uint32_t errorflag = 0;
1088#if defined (DUAL_BANK)
1090 if (Bank == FLASH_BANK_2)
1101 if(((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1113#if defined (DUAL_BANK)
1121 if((errorflag & 0x7FFFFFFFU) != 0U)
1124 pFlash.ErrorCode |= errorflag;
1141#if defined (DUAL_BANK)
1170 if(((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1221 if(((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1242#if defined (DUAL_BANK)
#define __IO
Defines 'read / write' permissions.
#define __DSB()
Data Synchronization Barrier.
#define __ISB()
Instruction Synchronization Barrier.
#define CLEAR_BIT(REG, BIT)
#define SET_BIT(REG, BIT)
#define WRITE_REG(REG, VAL)
#define READ_BIT(REG, BIT)
#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_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.
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.
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.
#define __HAL_UNLOCK(__HANDLE__)
#define __HAL_LOCK(__HANDLE__)
FLASH handle Structure definition.