Option Bytes Programming functions.
More...
Option Bytes Programming functions.
===============================================================================
##### Option Bytes Programming functions #####
===============================================================================
[..] The FLASH_Option Bytes Programming_functions, includes the following functions:
(+) void FLASH_OB_Unlock(void);
(+) void FLASH_OB_Lock(void);
(+) void FLASH_OB_Launch(void);
(+) FLASH_Status FLASH_OB_Erase(void);
(+) FLASH_Status FLASH_OB_EnableWRP(uint32_t OB_WRP);
(+) FLASH_Status FLASH_OB_RDPConfig(uint8_t OB_RDP);
(+) FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY);
(+) FLASH_Status FLASH_OB_BOOTConfig(uint8_t OB_BOOT1);
(+) FLASH_Status FLASH_OB_VDDAConfig(uint8_t OB_VDDA_ANALOG);
(+) FLASH_Status FLASH_OB_VDD_SD12Config(uint8_t OB_VDD_SD12);
(+) FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER);
(+) uint8_t FLASH_OB_GetUser(void);
(+) uint32_t FLASH_OB_GetWRP(void);
(+) FlagStatus FLASH_OB_GetRDP(void);
[..] Any operation of erase or program should follow these steps:
(#) Call the FLASH_OB_Unlock() function to enable the Option Bytes registers access
(#) Call one or several functions to program the desired option bytes
(++) FLASH_Status FLASH_OB_RDPConfig(uint8_t OB_RDP) => to set the desired read Protection Level
(++) FLASH_Status FLASH_OB_EnableWRP(uint32_t OB_WRP)
=> to Enable/Disable the desired sector write protection
(++) FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY)
=> to configure the user option Bytes: IWDG, STOP and the Standby.
(++) FLASH_Status FLASH_OB_BOOTConfig(uint8_t OB_BOOT1)
=> to set or reset BOOT1
(++) FLASH_Status FLASH_OB_VDDAConfig(uint8_t OB_VDDA_ANALOG)
=> to enable or disable the VDDA Analog Monitoring
(++) FLASH_Status FLASH_OB_VDD_SD12Config(uint8_t OB_VDD_SD12)
=> to Enable/Disable the VDD_SD12 monotoring
(++) You can write all User Options bytes at once using a single function
by calling FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER)
(#) Once all needed option bytes to be programmed are correctly written, call the
FLASH_OB_Launch(void) function to launch the Option Bytes programming process.
(#) Call the FLASH_OB_Lock() to disable the Option Bytes registers access (recommended
to protect the option Bytes against possible unwanted operations)
Sets or resets the BOOT1 option bit.
- Parameters
-
OB_BOOT1,: | Set or Reset the BOOT1 option bit. This parameter can be one of the following values:
- OB_BOOT1_RESET: BOOT1 option bit reset
- OB_BOOT1_SET: BOOT1 option bit set
|
- Return values
-
Write protects the desired pages.
- Note
- To correctly run this function, the FLASH_OB_Unlock() function must be called before.
-
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
OB_WRP,: | specifies the address of the pages to be write protected. This parameter can be:
- OB_WRP_Pages0to1..OB_WRP_Pages62to127
- OB_WRP_AllPages
|
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
Erases the FLASH option bytes.
- Note
- To correctly run this function, the FLASH_OB_Unlock() function must be called before.
-
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
-
This functions erases all option bytes except the Read protection (RDP).
- Parameters
-
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
FlagStatus FLASH_OB_GetRDP |
( |
void |
| ) |
|
Checks whether the FLASH Read out Protection Status is set or not.
- Parameters
-
- Return values
-
FLASH | ReadOut Protection Status(SET or RESET) |
uint8_t FLASH_OB_GetUser |
( |
void |
| ) |
|
Returns the FLASH User Option Bytes values.
- Parameters
-
- Return values
-
The | FLASH User Option Bytes . |
uint32_t FLASH_OB_GetWRP |
( |
void |
| ) |
|
Returns the FLASH Write Protection Option Bytes value.
- Parameters
-
- Return values
-
The | FLASH Write Protection Option Bytes value |
void FLASH_OB_Launch |
( |
void |
| ) |
|
Launch the option byte loading.
- Parameters
-
- Return values
-
void FLASH_OB_Lock |
( |
void |
| ) |
|
Locks the option bytes block access.
- Parameters
-
- Return values
-
FLASH_Status FLASH_OB_ProgramData |
( |
uint32_t |
Address, |
|
|
uint8_t |
Data |
|
) |
| |
Programs a half word at a specified Option Byte Data address.
- Note
- To correctly run this function, the FLASH_OB_Unlock() function must be called before.
-
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
Address,: | specifies the address to be programmed. This parameter can be 0x1FFFF804 or 0x1FFFF806. |
Data,: | specifies the data to be programmed. |
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
Enables or disables the read out protection.
- Note
- To correctly run this function, the FLASH_OB_Unlock() function must be called before.
-
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
FLASH_ReadProtection_Level,: | specifies the read protection level. This parameter can be:
- OB_RDP_Level_0: No protection
- OB_RDP_Level_1: Read protection of the memory
- OB_RDP_Level_2: Chip protection
|
- Note
- When enabling OB_RDP level 2 it's no more possible to go back to level 1 or 0
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
FLASH_Status FLASH_OB_SRAMParityConfig |
( |
uint8_t |
OB_SRAM_Parity | ) |
|
Sets or resets the SRAM partiy.
- Parameters
-
OB_SRAM_Parity,: | SSet or Reset the SRAM partiy enable bit. This parameter can be one of the following values:
- OB_SRAM_PARITY_SET: Set SRAM partiy.
- OB_SRAM_PARITY_RESET: Reset SRAM partiy.
|
- Return values
-
void FLASH_OB_Unlock |
( |
void |
| ) |
|
Unlocks the option bytes block access.
- Parameters
-
- Return values
-
FLASH_Status FLASH_OB_UserConfig |
( |
uint8_t |
OB_IWDG, |
|
|
uint8_t |
OB_STOP, |
|
|
uint8_t |
OB_STDBY |
|
) |
| |
Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.
- Note
- To correctly run this function, the FLASH_OB_Unlock() function must be called before.
-
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
OB_IWDG,: | Selects the WDG mode This parameter can be one of the following values:
- OB_IWDG_SW: Software WDG selected
- OB_IWDG_HW: Hardware WDG selected
|
OB_STOP,: | Reset event when entering STOP mode. This parameter can be one of the following values:
- OB_STOP_NoRST: No reset generated when entering in STOP
- OB_STOP_RST: Reset generated when entering in STOP
|
OB_STDBY,: | Reset event when entering Standby mode. This parameter can be one of the following values:
- OB_STDBY_NoRST: No reset generated when entering in STANDBY
- OB_STDBY_RST: Reset generated when entering in STANDBY
|
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
Sets or resets the analogue monitoring on VDD_SD12 Power source.
- Parameters
-
OB_VDD_SD12,: | Selects the analog monitoring on VDD_SD12 Power source. This parameter can be one of the following values:
- OB_VDD_SD12_ON: Analog monitoring on VDD_SD12 Power source ON
- OB_VDD_SD12_OFF: Analog monitoring on VDD_SD12 Power source OFF
|
- Return values
-
Sets or resets the analogue monitoring on VDDA Power source.
- Parameters
-
OB_VDDA_ANALOG,: | Selects the analog monitoring on VDDA Power source. This parameter can be one of the following values:
- OB_VDDA_ANALOG_ON: Analog monitoring on VDDA Power source ON
- OB_VDDA_ANALOG_OFF: Analog monitoring on VDDA Power source OFF
|
- Return values
-
Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY/ BOOT1 / OB_VDDA_ANALOG and OB_VDD_SD12.
- Note
- To correctly run this function, the FLASH_OB_Unlock() function must be called before.
-
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
OB_USER,: | Selects all user option bytes This parameter is a combination of the following values:
- OB_IWDG_SW: Software WDG selected
- OB_IWDG_HW: Hardware WDG selected
- OB_STOP_NoRST: No reset generated when entering in STOP
- OB_STOP_RST: Reset generated when entering in STOP
- OB_STDBY_NoRST: No reset generated when entering in STANDBY
- OB_STDBY_RST: Reset generated when entering in STANDBY
- OB_BOOT1_RESET: BOOT1 Reset
- OB_BOOT1_SET: BOOT1 Set
- OB_VDDA_ANALOG_ON: Analog monitoring on VDDA Power source ON
- OB_VDDA_ANALOG_OFF: Analog monitoring on VDDA Power source OFF
- OB_VDD_SD12_ON: Analog monitoring on VDD_SD12 Power source ON
- OB_VDD_SD12_OFF: Analog monitoring on VDD_SD12 Power source OFF
|
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |