86 #ifdef HAL_FLASH_MODULE_ENABLED 93 #define SECTOR_MASK ((uint32_t)0xFFFFFF07) 94 #define FLASH_TIMEOUT_VALUE ((uint32_t)50000) 118 static HAL_StatusTypeDef FLASH_OB_BootAddressConfig(uint32_t BootOption, uint32_t Address);
119 static uint32_t FLASH_OB_GetUser(
void);
120 static uint32_t FLASH_OB_GetWRP(
void);
121 static uint8_t FLASH_OB_GetRDP(
void);
122 static uint32_t FLASH_OB_GetBOR(
void);
123 static uint32_t FLASH_OB_GetBootAddress(uint32_t BootOption);
125 #if defined (FLASH_OPTCR_nDBANK) 126 static void FLASH_MassErase(uint8_t VoltageRange, uint32_t Banks);
127 static HAL_StatusTypeDef FLASH_OB_UserConfig(uint32_t Wwdg, uint32_t Iwdg, uint32_t Stop, uint32_t Stdby, uint32_t Iwdgstop, \
128 uint32_t Iwdgstdby, uint32_t NDBank, uint32_t NDBoot);
130 static void FLASH_MassErase(uint8_t VoltageRange);
131 static HAL_StatusTypeDef FLASH_OB_UserConfig(uint32_t Wwdg, uint32_t Iwdg, uint32_t Stop, uint32_t Stdby, uint32_t Iwdgstop, uint32_t Iwdgstdby);
186 *SectorError = 0xFFFFFFFFU;
191 #if defined (FLASH_OPTCR_nDBANK) 192 FLASH_MassErase((uint8_t) pEraseInit->
VoltageRange, pEraseInit->Banks);
222 *SectorError = index;
266 #if defined (FLASH_OPTCR_nDBANK) 267 FLASH_MassErase((uint8_t) pEraseInit->
VoltageRange, pEraseInit->Banks);
315 status = FLASH_OB_EnableWRP(pOBInit->
WRPSector);
320 status = FLASH_OB_DisableWRP(pOBInit->
WRPSector);
327 status = FLASH_OB_RDP_LevelConfig(pOBInit->
RDPLevel);
333 #if defined (FLASH_OPTCR_nDBANK) 355 status = FLASH_OB_BOR_LevelConfig(pOBInit->
BORLevel);
392 pOBInit->
RDPLevel = FLASH_OB_GetRDP();
398 pOBInit->
BORLevel = FLASH_OB_GetBOR();
410 #if defined (FLASH_OPTCR_nDBANK) 431 static void FLASH_MassErase(uint8_t VoltageRange, uint32_t Banks)
439 if(Banks == FLASH_BANK_BOTH)
444 else if(Banks == FLASH_BANK_2)
479 uint32_t tmp_psize = 0;
503 if(Sector > FLASH_SECTOR_11)
510 FLASH->CR |= tmp_psize;
524 static uint32_t FLASH_OB_GetWRP(
void)
527 return ((uint32_t)(
FLASH->OPTCR & 0x0FFF0000));
567 static HAL_StatusTypeDef FLASH_OB_UserConfig(uint32_t Wwdg, uint32_t Iwdg, uint32_t Stop, uint32_t Stdby, uint32_t Iwdgstop, \
568 uint32_t Iwdgstdby, uint32_t NDBank, uint32_t NDBoot)
570 uint32_t useroptionmask = 0x00;
571 uint32_t useroptionvalue = 0x00;
594 useroptionvalue = (Iwdg | Wwdg | Stop | Stdby | Iwdgstop | Iwdgstdby | NDBoot | NDBank);
608 static uint32_t FLASH_OB_GetUser(
void)
611 return ((uint32_t)(
FLASH->OPTCR & 0xF00000F0U));
630 static void FLASH_MassErase(uint8_t VoltageRange)
663 uint32_t tmp_psize = 0;
688 FLASH->CR |= tmp_psize;
689 FLASH->CR &= SECTOR_MASK;
702 static uint32_t FLASH_OB_GetWRP(
void)
705 return ((uint32_t)(
FLASH->OPTCR & 0x00FF0000));
736 static HAL_StatusTypeDef FLASH_OB_UserConfig(uint32_t Wwdg, uint32_t Iwdg, uint32_t Stop, uint32_t Stdby, uint32_t Iwdgstop, uint32_t Iwdgstdby)
738 uint32_t useroptionmask = 0x00;
739 uint32_t useroptionvalue = 0x00;
759 useroptionvalue = (Iwdg | Wwdg | Stop | Stdby | Iwdgstop | Iwdgstdby);
774 static uint32_t FLASH_OB_GetUser(
void)
777 return ((uint32_t)(
FLASH->OPTCR & 0xC00000F0));
810 FLASH->OPTCR &= (~WRPSector);
846 FLASH->OPTCR |= (WRPSector);
923 static HAL_StatusTypeDef FLASH_OB_BootAddressConfig(uint32_t BootOption, uint32_t Address)
956 static uint8_t FLASH_OB_GetRDP(
void)
984 static uint32_t FLASH_OB_GetBOR(
void)
987 return ((uint32_t)(
FLASH->OPTCR & 0x0C));
1007 static uint32_t FLASH_OB_GetBootAddress(uint32_t BootOption)
1009 uint32_t Address = 0;
#define CLEAR_BIT(REG, BIT)
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange)
FLASH Erase structure definition.
#define FLASH_FLAG_ERSERR
HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError)
#define OPTCR_BYTE1_ADDRESS
OPTCR register byte 1 (Bits[15:8]) base address.
#define IS_OB_BOR_LEVEL(LEVEL)
#define assert_param(expr)
Include module's header file.
#define IS_OB_STDBY_SOURCE(SOURCE)
#define FLASH_OPTCR_IWDG_SW
#define IS_OB_IWDG_STDBY_FREEZE(FREEZE)
#define __HAL_UNLOCK(__HANDLE__)
#define IS_VOLTAGERANGE(RANGE)
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit)
#define FLASH_OPTCR1_BOOT_ADD1
#define IS_OB_BOOT_ADDRESS(ADDRESS)
#define FLASH_FLAG_PGAERR
#define IS_OB_RDP_LEVEL(LEVEL)
#define FLASH_PSIZE_HALF_WORD
__IO FLASH_ProcedureTypeDef ProcedureOnGoing
#define POSITION_VAL(VAL)
#define FLASH_FLAG_WRPERR
#define IS_OB_WWDG_SOURCE(SOURCE)
FLASH handle Structure definition.
#define IS_FLASH_NBSECTORS(NBSECTORS)
#define FLASH_TYPEERASE_MASSERASE
#define __HAL_LOCK(__HANDLE__)
#define FLASH_OPTCR_BOR_LEV
#define OB_IWDG_STOP_ACTIVE
#define __DSB()
Data Synchronization Barrier.
void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit)
#define FLASH_OPTCR_IWDG_STDBY
__IO uint32_t NbSectorsToErase
#define IS_WRPSTATE(VALUE)
#define FLASH_OPTCR1_BOOT_ADD0
#define FLASH_VOLTAGE_RANGE_3
HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit)
#define IS_OB_STOP_SOURCE(SOURCE)
This file contains all the functions prototypes for the HAL module driver.
#define OPTIONBYTE_BOOTADDR_1
#define FLASH_VOLTAGE_RANGE_1
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
#define FLASH_OPTCR_WWDG_SW
#define OPTIONBYTE_BOOTADDR_0
#define __HAL_FLASH_CLEAR_FLAG(__FLAG__)
Clear the specified FLASH flag.
#define OB_IWDG_STDBY_ACTIVE
#define FLASH_OPTCR_nRST_STOP
#define IS_OPTIONBYTE(VALUE)
#define OB_WRPSTATE_ENABLE
#define FLASH_FLAG_PGPERR
__IO uint8_t VoltageForErase
#define IS_FLASH_TYPEERASE(VALUE)
#define IS_OB_IWDG_STOP_FREEZE(FREEZE)
FLASH Option Bytes Program structure definition.
#define FLASH_OPTCR_IWDG_STOP
HAL_StatusTypeDef
HAL Status structures definition.
#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__)
Enable the specified FLASH interrupt.
#define FLASH_OPTCR_nDBANK
#define FLASH_VOLTAGE_RANGE_2
#define IS_OB_IWDG_SOURCE(SOURCE)
#define FLASH_PSIZE_DOUBLE_WORD