FLASH_Status FLASH_GetStatus(void)
{
FLASH_Status flashstatus = FLASH_COMPLETE;
if((FLASH->SR & FLASH_FLAG_BSY) == FLASH_FLAG_BSY)
{
flashstatus = FLASH_BUSY;
}
else
{
if((FLASH->SR & FLASH_FLAG_WRPERR) != (uint32_t)0x00)
{
flashstatus = FLASH_ERROR_WRP;
}
else
{
/*
这句是否应该是if((FLASH->SR & (uint32_t)0xE0) != (uint32_t)0x00)才对啊
OPERR: Operation error和EOP: End of operation是在中断使能时(ERRIE = 1EOPIE =1)才置位的
假设EOP位为1,将返回FLASH_ERROR_PROGRAM,EOP为1不代表编程出错吧
*/
if((FLASH->SR & (uint32_t)0xEF) != (uint32_t)0x00)
{
flashstatus = FLASH_ERROR_PROGRAM;
}
else
{
if((FLASH->SR & FLASH_FLAG_OPERR) != (uint32_t)0x00)
{
flashstatus = FLASH_ERROR_OPERATION;
}
else
{
flashstatus = FLASH_COMPLETE;
}
}
}
}
/* Return the FLASH Status */
return flashstatus;
} |