stm32: flash_unlock_option_bytes is common code.
The keys differ between some familes, but the documentation and implementation are standard.
This commit is contained in:
@@ -43,6 +43,10 @@ void flash_set_ws(uint32_t ws)
|
||||
FLASH_ACR = reg32;
|
||||
}
|
||||
|
||||
|
||||
void flash_unlock_option_bytes(void)
|
||||
{
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY1;
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY2;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -85,20 +85,6 @@ void flash_program_word(uint32_t address, uint32_t data)
|
||||
flash_program_half_word(address+2, (uint16_t)(data>>16));
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Unlock the Option Byte Access
|
||||
|
||||
This enables write access to the option bytes. It is locked by default on
|
||||
reset.
|
||||
*/
|
||||
|
||||
void flash_unlock_option_bytes(void)
|
||||
{
|
||||
/* F1 uses same keys for flash and option */
|
||||
FLASH_OPTKEYR = FLASH_KEYR_KEY1;
|
||||
FLASH_OPTKEYR = FLASH_KEYR_KEY2;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Erase All Option Bytes
|
||||
|
||||
|
||||
@@ -87,19 +87,6 @@ void flash_clear_status_flags(void)
|
||||
flash_clear_eop_flag();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Unlock the Option Byte Access
|
||||
|
||||
This enables write access to the option bytes. It is locked by default on
|
||||
reset.
|
||||
*/
|
||||
|
||||
void flash_unlock_option_bytes(void)
|
||||
{
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY1;
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY2;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Lock the Option Byte Access
|
||||
|
||||
|
||||
@@ -64,18 +64,6 @@ void flash_lock_progmem(void)
|
||||
FLASH_PECR |= FLASH_PECR_PRGLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock option bytes.
|
||||
* Writes the magic sequence to unlock the option bytes,
|
||||
* you must have already unlocked access to this register!
|
||||
* @sa flash_unlock_pecr
|
||||
*/
|
||||
void flash_unlock_option_bytes(void)
|
||||
{
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY1;
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY2;
|
||||
}
|
||||
|
||||
void flash_lock_option_bytes(void)
|
||||
{
|
||||
FLASH_PECR |= FLASH_PECR_OPTLOCK;
|
||||
|
||||
@@ -82,19 +82,6 @@ void flash_wait_for_last_operation(void)
|
||||
while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Unlock the Option Byte Access
|
||||
|
||||
This enables write access to the option bytes. It is locked by default on
|
||||
reset.
|
||||
*/
|
||||
|
||||
void flash_unlock_option_bytes(void)
|
||||
{
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY1;
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY2;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Lock the Option Byte Access
|
||||
|
||||
|
||||
@@ -92,16 +92,6 @@ void flash_clear_status_flags(void)
|
||||
flash_clear_eop_flag();
|
||||
}
|
||||
|
||||
/** @brief Unlock the Option Byte Access
|
||||
* This enables write access to the option bytes. It is locked by default on
|
||||
* reset.
|
||||
*/
|
||||
void flash_unlock_option_bytes(void)
|
||||
{
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY1;
|
||||
FLASH_OPTKEYR = FLASH_OPTKEYR_KEY2;
|
||||
}
|
||||
|
||||
/** @brief Lock the Option Byte Access
|
||||
* This disables write access to the option bytes. It is locked by default on
|
||||
* reset.
|
||||
|
||||
Reference in New Issue
Block a user