本帖最后由 IFELSERETURN 于 2023-8-25 16:57 编辑
--write_update_flag是入口函数
void write_update_flag(uint32_t flag) {
if(FMC_flash_write_word(0x80FC00, 0xaa))
printf("FMC_flash_write_word success\n");
else
printf("FMC_flash_write_word error\n");
FMC_flash_read_word(0x80FC00);
}
uint8_t FMC_flash_write_word(uint32_t address, uint32_t pData)
{
fmc_state_enum FLASHStatus;
uint32_t AddressTemp = 0;
AddressTemp = address ;
printf("FMC_flash_write_word write: %d \r\n",pData);
fmc_unlock();
fmc_page_erase(AddressTemp);
fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_WPERR | FMC_FLAG_PGERR);
FLASHStatus = fmc_word_program(AddressTemp, pData);
if (*((volatile uint32_t*)AddressTemp) != pData){
printf("write error\n");
return 0;
}
if (FLASHStatus != FMC_READY){
printf("FLASHStatus != FMC_READY\n");
return 0;
}
fmc_lock();
return 1;
}
|