Flash
About Sectors
Read out
#define FLASH_TYPE E_FL_CHIP_INTERNAL
#define FLASH_SECTOR_SIZE (32L* 1024L) // 32KB
#define FLASH_SECTOR_NUMBER 5 // 0..4 (for TWELITE BLUE)
/** @ingroup FLASH
* Read out from Flash
* @param psFlash data buffer for storing.
* @param sector readout sector
* @param offset Offset from the beginning of the sector
* @return TRUE: Read successfully FALSE: Failure
*/
bool_t bFlash_Read(tsFlash *psFlash, uint8 sector, uint32 offset) {
bool_t bRet = FALSE;
offset += (uint32)sector * FLASH_SECTOR_SIZE; // calculate the absolute address
if (bAHI_FlashInit(FLASH_TYPE, NULL) == TRUE) {
if (bAHI_FullFlashRead(offset, sizeof(tsFlash), (uint8 *)psFlash)) {
bRet = TRUE;
}
}
// validate content
if (bRet && psFlash->u32Magic != FLASH_MAGIC_NUMBER) {
bRet = FALSE;
}
if (bRet && psFlash->u8CRC != u8CCITT8((uint8*)&(psFlash->sData), sizeof(tsFlashApp))) {
bRet = FALSE;
}
return bRet;
}
Writing
Erase
最終更新