zebra joint controller firmware (originally from MIT HKC motor controller by benkatz)
Option Bytes Programming functions
[FLASH_Private_Functions]
Option Bytes Programming functions. More...
Functions | |
void | FLASH_OB_Unlock (void) |
Unlocks the FLASH Option Control Registers access. | |
void | FLASH_OB_Lock (void) |
Locks the FLASH Option Control Registers access. | |
void | FLASH_OB_WRPConfig (uint32_t OB_WRP, FunctionalState NewState) |
Enables or disables the write protection of the desired sectors, for the first 1 Mb of the Flash. | |
void | FLASH_OB_WRP1Config (uint32_t OB_WRP, FunctionalState NewState) |
Enables or disables the write protection of the desired sectors, for the second 1 Mb of the Flash. | |
void | FLASH_OB_PCROPSelectionConfig (uint8_t OB_PcROP) |
Select the Protection Mode (SPRMOD). | |
void | FLASH_OB_PCROPConfig (uint32_t OB_PCROP, FunctionalState NewState) |
Enables or disables the read/write protection (PCROP) of the desired sectors, for the first 1 MB of the Flash. | |
void | FLASH_OB_PCROP1Config (uint32_t OB_PCROP, FunctionalState NewState) |
Enables or disables the read/write protection (PCROP) of the desired sectors. | |
void | FLASH_OB_RDPConfig (uint8_t OB_RDP) |
Sets the read protection level. | |
void | 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. | |
void | FLASH_OB_BootConfig (uint8_t OB_BOOT) |
Configure the Dual Bank Boot. | |
void | FLASH_OB_BORConfig (uint8_t OB_BOR) |
Sets the BOR Level. | |
FLASH_Status | FLASH_OB_Launch (void) |
Launch the option byte loading. | |
uint8_t | FLASH_OB_GetUser (void) |
Returns the FLASH User Option Bytes values. | |
uint16_t | FLASH_OB_GetWRP (void) |
Returns the FLASH Write Protection Option Bytes value. | |
uint16_t | FLASH_OB_GetWRP1 (void) |
Returns the FLASH Write Protection Option Bytes value. | |
uint16_t | FLASH_OB_GetPCROP (void) |
Returns the FLASH PC Read/Write Protection Option Bytes value. | |
uint16_t | FLASH_OB_GetPCROP1 (void) |
Returns the FLASH PC Read/Write Protection Option Bytes value. | |
FlagStatus | FLASH_OB_GetRDP (void) |
Returns the FLASH Read Protection level. | |
uint8_t | FLASH_OB_GetBOR (void) |
Returns the FLASH BOR level. |
Detailed Description
Option Bytes Programming functions.
=============================================================================== ##### Option Bytes Programming functions ##### =============================================================================== [..] This group includes the following functions: (+) void FLASH_OB_Unlock(void) (+) void FLASH_OB_Lock(void) (+) void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState) (+) void FLASH_OB_WRP1Config(uint32_t OB_WRP, FunctionalState NewState) (+) void FLASH_OB_PCROPSelectionConfig(uint8_t OB_PCROPSelect) (+) void FLASH_OB_PCROPConfig(uint32_t OB_PCROP, FunctionalState NewState) (+) void FLASH_OB_PCROP1Config(uint32_t OB_PCROP, FunctionalState NewState) (+) void FLASH_OB_RDPConfig(uint8_t OB_RDP) (+) void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY) (+) void FLASH_OB_BORConfig(uint8_t OB_BOR) (+) FLASH_Status FLASH_ProgramOTP(uint32_t Address, uint32_t Data) (+) FLASH_Status FLASH_OB_Launch(void) (+) uint32_t FLASH_OB_GetUser(void) (+) uint8_t FLASH_OB_GetWRP(void) (+) uint8_t FLASH_OB_GetWRP1(void) (+) uint8_t FLASH_OB_GetPCROP(void) (+) uint8_t FLASH_OB_GetPCROP1(void) (+) uint8_t FLASH_OB_GetRDP(void) (+) uint8_t FLASH_OB_GetBOR(void) [..] The following function can be used only for STM32F42xxx/43xxx devices. (+) void FLASH_OB_BootConfig(uint8_t OB_BOOT) [..] Any operation of erase or program should follow these steps: (#) Call the FLASH_OB_Unlock() function to enable the FLASH option control register access (#) Call one or several functions to program the desired Option Bytes: (++) void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState) => to Enable/Disable the desired sector write protection (++) void FLASH_OB_RDPConfig(uint8_t OB_RDP) => to set the desired read Protection Level (++) void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY) => to configure the user Option Bytes. (++) void FLASH_OB_BORConfig(uint8_t OB_BOR) => to set the BOR Level (#) Once all needed Option Bytes to be programmed are correctly written, call the FLASH_OB_Launch() function to launch the Option Bytes programming process. -@- When changing the IWDG mode from HW to SW or from SW to HW, a system reset is needed to make the change effective. (#) Call the FLASH_OB_Lock() function to disable the FLASH option control register access (recommended to protect the Option Bytes against possible unwanted operations)
Function Documentation
void FLASH_OB_BootConfig | ( | uint8_t | OB_BOOT ) |
Configure the Dual Bank Boot.
- Note:
- This function can be used only for STM32F42xxx/43xxx devices.
- Parameters:
-
OB_BOOT,: specifies the Dual Bank Boot Option byte. This parameter can be one of the following values: - OB_Dual_BootEnabled: Dual Bank Boot Enable
- OB_Dual_BootDisabled: Dual Bank Boot Disabled
- Return values:
-
None
Definition at line 1278 of file stm32f4xx_flash.c.
void FLASH_OB_BORConfig | ( | uint8_t | OB_BOR ) |
Sets the BOR Level.
- Parameters:
-
OB_BOR,: specifies the Option Bytes BOR Reset Level. This parameter can be one of the following values: - OB_BOR_LEVEL3: Supply voltage ranges from 2.7 to 3.6 V
- OB_BOR_LEVEL2: Supply voltage ranges from 2.4 to 2.7 V
- OB_BOR_LEVEL1: Supply voltage ranges from 2.1 to 2.4 V
- OB_BOR_OFF: Supply voltage ranges from 1.62 to 2.1 V
- Return values:
-
None
Definition at line 1299 of file stm32f4xx_flash.c.
uint8_t FLASH_OB_GetBOR | ( | void | ) |
Returns the FLASH BOR level.
- Parameters:
-
None
- Return values:
-
The FLASH BOR level: - OB_BOR_LEVEL3: Supply voltage ranges from 2.7 to 3.6 V
- OB_BOR_LEVEL2: Supply voltage ranges from 2.4 to 2.7 V
- OB_BOR_LEVEL1: Supply voltage ranges from 2.1 to 2.4 V
- OB_BOR_OFF : Supply voltage ranges from 1.62 to 2.1 V
Definition at line 1425 of file stm32f4xx_flash.c.
uint16_t FLASH_OB_GetPCROP | ( | void | ) |
Returns the FLASH PC Read/Write Protection Option Bytes value.
- Note:
- This function can be used only for STM32F42xxx/43xxx devices and STM32F401xx/411xE devices.
- Parameters:
-
None
- Return values:
-
The FLASH PC Read/Write Protection Option Bytes value
Definition at line 1374 of file stm32f4xx_flash.c.
uint16_t FLASH_OB_GetPCROP1 | ( | void | ) |
Returns the FLASH PC Read/Write Protection Option Bytes value.
- Note:
- This function can be used only for STM32F42xxx/43xxx devices.
- Parameters:
-
None
- Return values:
-
The FLASH PC Read/Write Protection Option Bytes value
Definition at line 1388 of file stm32f4xx_flash.c.
FlagStatus FLASH_OB_GetRDP | ( | void | ) |
Returns the FLASH Read Protection level.
- Parameters:
-
None
- Return values:
-
FLASH ReadOut Protection Status: - SET, when OB_RDP_Level_1 or OB_RDP_Level_2 is set
- RESET, when OB_RDP_Level_0 is set
Definition at line 1401 of file stm32f4xx_flash.c.
uint8_t FLASH_OB_GetUser | ( | void | ) |
Returns the FLASH User Option Bytes values.
- Parameters:
-
None
- Return values:
-
The FLASH User Option Bytes values: IWDG_SW(Bit0), RST_STOP(Bit1) and RST_STDBY(Bit2).
Definition at line 1335 of file stm32f4xx_flash.c.
uint16_t FLASH_OB_GetWRP | ( | void | ) |
Returns the FLASH Write Protection Option Bytes value.
- Parameters:
-
None
- Return values:
-
The FLASH Write Protection Option Bytes value
Definition at line 1346 of file stm32f4xx_flash.c.
uint16_t FLASH_OB_GetWRP1 | ( | void | ) |
Returns the FLASH Write Protection Option Bytes value.
- Note:
- This function can be used only for STM32F42xxx/43xxx devices.
- Parameters:
-
None
- Return values:
-
The FLASH Write Protection Option Bytes value
Definition at line 1360 of file stm32f4xx_flash.c.
FLASH_Status FLASH_OB_Launch | ( | void | ) |
Launch the option byte loading.
- Parameters:
-
None
- Return values:
-
FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.
Definition at line 1316 of file stm32f4xx_flash.c.
void FLASH_OB_Lock | ( | void | ) |
Locks the FLASH Option Control Registers access.
- Parameters:
-
None
- Return values:
-
None
Definition at line 986 of file stm32f4xx_flash.c.
void FLASH_OB_PCROP1Config | ( | uint32_t | OB_PCROP, |
FunctionalState | NewState | ||
) |
Enables or disables the read/write protection (PCROP) of the desired sectors.
- Note:
- This function can be used only for STM32F42xxx/43xxx devices.
- Parameters:
-
OB_PCROP,: specifies the sector(s) to be read/write protected or unprotected. This parameter can be one of the following values: - OB_PCROP: A value between OB_PCROP_Sector12 and OB_PCROP_Sector23
- OB_PCROP_Sector_All
Newstate,: new state of the Write Protection. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
Definition at line 1169 of file stm32f4xx_flash.c.
void FLASH_OB_PCROPConfig | ( | uint32_t | OB_PCROP, |
FunctionalState | NewState | ||
) |
Enables or disables the read/write protection (PCROP) of the desired sectors, for the first 1 MB of the Flash.
- Note:
- This function can be used only for STM32F42xxx/43xxx , STM32F401xx/411xE and STM32F412xG devices.
- Parameters:
-
OB_PCROP,: specifies the sector(s) to be read/write protected or unprotected. This parameter can be one of the following values: - OB_PCROP: A value between OB_PCROP_Sector0 and OB_PCROP_Sector11 for STM32F42xxx/43xxx devices and between OB_PCROP_Sector0 and OB_PCROP_Sector5 for STM32F401xx/411xE devices.
- OB_PCROP_Sector_All
Newstate,: new state of the Write Protection. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
Definition at line 1132 of file stm32f4xx_flash.c.
void FLASH_OB_PCROPSelectionConfig | ( | uint8_t | OB_PcROP ) |
Select the Protection Mode (SPRMOD).
- Note:
- This function can be used only for STM32F42xxx/43xxx and STM32F401xx/411xE devices.
- After PCROP activation, Option Byte modification is not possible. Exception made for the global Read Out Protection modification level (level1 to level0)
- Once SPRMOD bit is active unprotection of a protected sector is not possible
- Read a protected sector will set RDERR Flag and write a protected sector will set WRPERR Flag
-
Some Precautions should be taken when activating the PCROP feature : The active value of nWRPi bits is inverted when PCROP mode is active, this means if SPRMOD = 1 and WRPi = 1 (default value), then the user sector i is read/write protected. In order to avoid activation of PCROP Mode for undesired sectors, please follow the below safety sequence :
- Disable PCROP for all Sectors using FLASH_OB_PCROPConfig(OB_PCROP_Sector_All, DISABLE) function for Bank1 or FLASH_OB_PCROP1Config(OB_PCROP_Sector_All, DISABLE) function for Bank2
- Enable PCROP for the desired Sector i using FLASH_OB_PCROPConfig(Sector i, ENABLE) function
- Activate the PCROP Mode FLASH_OB_PCROPSelectionConfig() function.
- Parameters:
-
OB_PCROP,: Select the Protection Mode of nWPRi bits This parameter can be one of the following values: - OB_PcROP_Disable: nWRPi control the write protection of respective user sectors.
- OB_PcROP_Enable: nWRPi control the read&write protection (PCROP) of respective user sectors.
- Return values:
-
None
Definition at line 1101 of file stm32f4xx_flash.c.
void FLASH_OB_RDPConfig | ( | uint8_t | OB_RDP ) |
Sets the read protection level.
- Parameters:
-
OB_RDP,: specifies the read protection level. This parameter can be one of the following values: - OB_RDP_Level_0: No protection
- OB_RDP_Level_1: Read protection of the memory
- OB_RDP_Level_2: Full chip protection
/!\ Warning /!\ When enabling OB_RDP level 2 it's no more possible to go back to level 1 or 0
- Return values:
-
None
Definition at line 1205 of file stm32f4xx_flash.c.
void FLASH_OB_Unlock | ( | void | ) |
Unlocks the FLASH Option Control Registers access.
- Parameters:
-
None
- Return values:
-
None
Definition at line 971 of file stm32f4xx_flash.c.
void 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.
- Parameters:
-
OB_IWDG,: Selects the IWDG mode This parameter can be one of the following values: - OB_IWDG_SW: Software IWDG selected
- OB_IWDG_HW: Hardware IWDG 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:
-
None
Definition at line 1237 of file stm32f4xx_flash.c.
void FLASH_OB_WRP1Config | ( | uint32_t | OB_WRP, |
FunctionalState | NewState | ||
) |
Enables or disables the write protection of the desired sectors, for the second 1 Mb of the Flash.
- Note:
- This function can be used only for STM32F42xxx/43xxx devices.
- When the memory read out protection is selected (RDP level = 1), it is not possible to program or erase the flash sector i if CortexM4 debug features are connected or boot code is executed in RAM, even if nWRPi = 1
- Active value of nWRPi bits is inverted when PCROP mode is active (SPRMOD =1).
- Parameters:
-
OB_WRP,: specifies the sector(s) to be write protected or unprotected. This parameter can be one of the following values: - OB_WRP: A value between OB_WRP_Sector12 and OB_WRP_Sector23
- OB_WRP_Sector_All
Newstate,: new state of the Write Protection. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
Definition at line 1051 of file stm32f4xx_flash.c.
void FLASH_OB_WRPConfig | ( | uint32_t | OB_WRP, |
FunctionalState | NewState | ||
) |
Enables or disables the write protection of the desired sectors, for the first 1 Mb of the Flash.
- Note:
- When the memory read protection level is selected (RDP level = 1), it is not possible to program or erase the flash sector i if CortexM4 debug features are connected or boot code is executed in RAM, even if nWRPi = 1
- Active value of nWRPi bits is inverted when PCROP mode is active (SPRMOD =1).
- Parameters:
-
OB_WRP,: specifies the sector(s) to be write protected or unprotected. This parameter can be one of the following values: - OB_WRP: A value between OB_WRP_Sector0 and OB_WRP_Sector11
- OB_WRP_Sector_All
Newstate,: new state of the Write Protection. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
Definition at line 1009 of file stm32f4xx_flash.c.
Generated on Sun Jul 17 2022 04:31:50 by 1.7.2