Изменения на новые настройки пинов и устройств
This commit is contained in:
parent
0e89352650
commit
a8ad10b9a0
|
|
@ -558,51 +558,46 @@ flash_status_type flash_bank2_erase(void)
|
|||
*/
|
||||
flash_status_type flash_user_system_data_erase(void)
|
||||
{
|
||||
flash_status_type status = FLASH_OPERATE_DONE;
|
||||
uint16_t fap_val = FAP_RELIEVE_KEY;
|
||||
/* get the flash access protection status */
|
||||
if(flash_fap_status_get() != RESET)
|
||||
{
|
||||
fap_val = 0x0000;
|
||||
}
|
||||
|
||||
/* wait for last operation to be completed */
|
||||
status = flash_operation_wait_for(ERASE_TIMEOUT);
|
||||
|
||||
if(status == FLASH_OPERATE_DONE)
|
||||
{
|
||||
flash_status_type status = FLASH_OPERATE_DONE;
|
||||
uint16_t fap_val = FAP_RELIEVE_KEY;
|
||||
/* get the flash access protection status */
|
||||
if(flash_fap_status_get() != RESET)
|
||||
{
|
||||
fap_val = 0x0000;
|
||||
}
|
||||
|
||||
/* unlock the user system data */
|
||||
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
|
||||
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
|
||||
while(FLASH->ctrl_bit.usdulks==RESET);
|
||||
|
||||
|
||||
/* erase the user system data */
|
||||
FLASH->ctrl_bit.usders = TRUE;
|
||||
FLASH->ctrl_bit.erstr = TRUE;
|
||||
|
||||
|
||||
/* wait for operation to be completed */
|
||||
status = flash_operation_wait_for(ERASE_TIMEOUT);
|
||||
|
||||
|
||||
/* disable the usders bit */
|
||||
FLASH->ctrl_bit.usders = FALSE;
|
||||
|
||||
if((status == FLASH_OPERATE_DONE) && (fap_val == FAP_RELIEVE_KEY))
|
||||
{
|
||||
/* enable the user system data programming operation */
|
||||
FLASH->ctrl_bit.usdprgm = TRUE;
|
||||
|
||||
/* restore the last flash access protection value */
|
||||
USD->fap = (uint16_t)fap_val;
|
||||
|
||||
/* wait for operation to be completed */
|
||||
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
|
||||
|
||||
/*disable the usdprgm bit */
|
||||
FLASH->ctrl_bit.usdprgm = FALSE;
|
||||
/* enable the user system data programming operation */
|
||||
FLASH->ctrl_bit.usdprgm = TRUE;
|
||||
|
||||
/* restore the last flash access protection value */
|
||||
USD->fap = (uint16_t)fap_val;
|
||||
|
||||
/* wait for operation to be completed */
|
||||
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
|
||||
|
||||
/*disable the usdprgm bit */
|
||||
FLASH->ctrl_bit.usdprgm = FALSE;
|
||||
}
|
||||
}
|
||||
/* return the status */
|
||||
return status;
|
||||
|
||||
/* return the status */
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -623,34 +618,30 @@ flash_status_type flash_user_system_data_erase(void)
|
|||
*/
|
||||
flash_status_type flash_eopb0_config(flash_usd_eopb0_type data)
|
||||
{
|
||||
flash_status_type status = FLASH_OPERATE_DONE;
|
||||
|
||||
/* wait for last operation to be completed */
|
||||
status = flash_operation_wait_for(ERASE_TIMEOUT);
|
||||
|
||||
if(status == FLASH_OPERATE_DONE)
|
||||
{
|
||||
flash_status_type status = FLASH_OPERATE_DONE;
|
||||
|
||||
/* unlock the user system data */
|
||||
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
|
||||
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
|
||||
while(FLASH->ctrl_bit.usdulks==RESET);
|
||||
|
||||
|
||||
/* enable the user system data programming operation */
|
||||
FLASH->ctrl_bit.usdprgm = TRUE;
|
||||
|
||||
/* restore the default eopb0 value */
|
||||
USD->eopb0 = (uint16_t)data;
|
||||
|
||||
|
||||
/* wait for operation to be completed */
|
||||
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
|
||||
|
||||
|
||||
/*disable the usdprgm bit */
|
||||
FLASH->ctrl_bit.usdprgm = FALSE;
|
||||
}
|
||||
/* return the status */
|
||||
return status;
|
||||
|
||||
/* return the status */
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief program a word at a specified address.
|
||||
* @param address: specifies the address to be programmed, word alignment is recommended.
|
||||
|
|
|
|||
Loading…
Reference in New Issue