void HalFlashRead(uint8 pg, uint16 offset, uint8 *buf, uint16 cnt)
{
// Calculate the offset into the containing flash bank as it gets mapped into XDATA.
uint8 *pData = (uint8 *)(offset + HAL_FLASH_PAGE_MAP) + ((pg % HAL_FLASH_PAGE_PER_BANK) * HAL_FLASH_PAGE_SIZE);
uint8 memctr = MEMCTR; // Save to restore.
#if (!defined HAL_OAD_BOOT_CODE) && (!defined HAL_OTA_BOOT_CODE)
halIntState_t is;
#endif
pg /= HAL_FLASH_PAGE_PER_BANK; // Calculate the flash bank from the flash page.
#if (!defined HAL_OAD_BOOT_CODE) && (!defined HAL_OTA_BOOT_CODE)
HAL_ENTER_CRITICAL_SECTION(is);
#endif
// Calculate and map the containing flash bank into XDATA.
MEMCTR = (MEMCTR & 0xF8) | pg;
while (cnt--)
{
*buf++ = *pData++;
}
MEMCTR = memctr;
#if (!defined HAL_OAD_BOOT_CODE) && (!defined HAL_OTA_BOOT_CODE)
HAL_EXIT_CRITICAL_SECTION(is);
#endif
}
不晓得如何用。不是很明白,我用没成功,不晓得自己的读的是那段, |