uint32_t MyFlash_ReadWord(uint32_t Address)
{
return *((__IO uint32_t *)(Address));
}
uint16_t MyFlash_ReadHalfWord(uint32_t Address)
{
return *((__IO uint16_t *)(Address));
}
uint8_t MyFlash_ReadByte(uint32_t Address)
{
return *((__IO uint8_t *)(Address));
}
void MyFlash_EraseAllPages(void)
{
FLASH_Unlock();
FLASH_EraseAllPages();
FLASH_Lock();
}
void MyFlash_EraseAPage(uint32_t PageAddress)
{
FLASH_Unlock();
FLASH_ErasePage(PageAddress);
FLASH_Lock();
}
void MyFlash_ProgramWord(uint32_t Address, uint32_t Data)
{
FLASH_Unlock();
FLASH_ProgramWord(Address, Data);
FLASH_Lock();
}
void MyFlash_ProgramWord(uint32_t Address, uint32_t Data)
{
FLASH_Unlock();
FLASH_ProgramHalfWord(Address, Data);
FLASH_Lock();
'对闪存读写的基本逻辑是:上电时将闪存读取到SRAM内存中,下电前再写回闪存,避免频繁的读写闪存'
'因为在读写FLASH闪存时,CPU会停止,会可能导致中断程序无法按时执行'
}