void SysInit(void)
{
FoscInit();
IrInit();
GpioInit();
PwmInit();
E2promInit();
if((E2promReadByte(0x4006)==0))//eeprom从未赋值过
{
FactoryResetData();//初始化需要保存到EEPROM的参数
}
}
void FactoryResetData(void)
{
E2promWriteByte(0,0); //clolr_index
E2promWriteByte(1,0);//display_mode
E2promWriteByte(2,1);//light_level
E2promWriteByte(3,1);//light_frequency
E2promWriteByte(4,0);//power
E2promWriteByte(5,0);//white_index
E2promWriteByte(6,1);//表明EEPROM已经初始化
E2promWriteByte(7,0);//flag_power_off
*((unsigned char*)0x4803) = 0x01;
*((unsigned char*)0x4804) = 0xfe;//PC5 PC6能输出PWM,option bytes;
}
|