TWELITE This is a procedure for using the built-in EEPROM of the wireless microcontroller.
Reads out the EEPROM.
bool_t EEP_6x_bRead(uint16 u16StartAddr, uint16 u16Bytes, uint8 *pu8Buffer);
Write to EEPROM.
bool_t EEP_6x_bWrite(uint16 u16StartAddr, uint16 u16Bytes, uint8 *pu8Buffer);
#include "eeprom_6x.h"
// read
if (EEP_6x_bRead(0, sizeof(tsSaveDat), (uint8 *)psSaveDat)) {
bRet = TRUE;
}
// write
psSaveDat->u32Magic = FLASH_MAGIC_NUMBER;
psSaveDat->u8CRC = u8CCITT8((uint8*)&(psSaveDat->sData), sizeof(tsSaveDat));
if (EEP_6x_bWrite(0, sizeof(tsSaveDat), (uint8 *)psSaveDat)) {
bRet = TRUE;
}
// clean up
uint8 au8buff[EEPROM_6X_SEGMENT_SIZE];
memset (au8buff, 0xFF, EEPROM_6X_SEGMENT_SIZE);
bRet = TRUE;
for (i = 0; i < EEPROM_6X_USER_SEGMENTS; i++) {
bRet &= EEP_6x_bWrite(i * EEPROM_6X_SEGMENT_SIZE,
EEPROM_6X_SEGMENT_SIZE,
au8buff);
}