#include "E2PROM.h"
static INT16U EEPROM_R[cwEEPROM_MAX];
static INT16U EEPROM_W[cwEEPROM_MAX];
void sFactorySET(void)
{
//请问,在这里如何建立参数初始化
}
void sRecovery(INT8U bTotal)
{
INT8U i;
eepromRead(0,EEPROM_R,cwEEPROM_MAX);
if (EEPROM_R[0] == 0xFFFF||EEPROM_R[0] == 0){
sFactorySET(); //所有参数第一次使用前将参数初始化
for (i= 0; i<bTotal-cwPASSIVE_CNT; i++){ //15个
EEPROM_W[i] = (INT16U)*((&g_wSYZJ)+i);
EEPROM_R[i] = (INT16U)*((&g_wSYZJ)+i);
}
eepromWriteNByte(EEPROM_W,0x300,cwEEPROM_MAX);
for (i= 0; i<bTotal; i++){
EEPROM_W[i] = (INT16U)*((&g_wSYZJ)+i);
}
eepromWriteNByte(EEPROM_W,0x0,cwEEPROM_MAX);
}else{
if (g_wCSHF==1){ //参数恢复
eepromRead(0x300,EEPROM_R,cwEEPROM_MAX);
for (i= 0; i<(bTotal-cwPASSIVE_CNT); i++){
*((&g_wSYZJ)+i) = EEPROM_R[i];
}
}else{
eepromRead(0x0,EEPROM_R,cwEEPROM_MAX);
for (i= 0; i<bTotal; i++){
*((&g_wSYZJ)+i) = EEPROM_R[i];
}
}
}
}
|