📄 eerom.c
字号:
#include <iom128v.h>
#include <macros.h>
#include <control.h>
#include <qam.h>
#define COM_BAUD 9600
#define COM_ADDR_H 0x0054
#define COM_ADDR_L 0x0055
#define PASSWORD_ADD 0X0060 //0X0054-0X0059
//the ethernet save address
#define NET_GATE 0x0070 //0x0054-0x0057
#define NET_SUB 0x0080 //0x0058-0x0061
#define NET_LIP 0x0090 //0x0062-0x0065
#define NET_DIP 0x00a0 //0x0066-0x0069
extern unsigned int VOL_H_valsaved[4],TEMP_H_valsaved[2];
extern unsigned int VOL_L_valsaved[4],TEMP_L_valsaved[2];
extern sound_swtich[4],sound_type_saved;
extern unsigned char net_gatway[4],net_sub[4],net_lip[4],net_dip[4];
extern unsigned int com_set;
extern unsigned char ucMenuQModSubPosition[8],ucMenuIFSubPosition[8];
extern unsigned int iSmbRatSaved[8];
extern unsigned char temperature_h[2],temperature_l[2],time[7];
extern unsigned char menu_password[6];
//---------------------------------------------------------
// NAME: write_eeprom()
// ENTRY: add,data
// RETURN: void
// MODIFY: 2004.2.3
//--------------------------------------------------------
void write_eeprom(unsigned int add,unsigned char data)
{
while(EECR&(1<<EEWE));
EEAR=add;
EEDR=data;
CLI();
EECR|=(1<<EEMWE);
EECR|=(1<<EEWE);
SEI();
}
//---------------------------------------------------------
// NAME: read_eeprom()
// ENTRY: add
// RETURN: void
// MODIFY: 2004.2.3
//--------------------------------------------------------
unsigned char read_eeprom(unsigned int add)
{
unsigned char data;
while(EECR&(1<<EEWE));
EEAR=add;
EECR|=(1<<EERE);
data=EEDR;
return(data);
}
//---------------------------------------------------------
// NAME: Eeprom_Init()
// ENTRY: void
// RETURN: void
// MODIFY: 2004.2.3
//--------------------------------------------------------
void Eeprom_Init(void)
{
unsigned char temp,temp1,i;
temp=read_eeprom(0x0010);//FLAG_ADDR);
if(temp==0x5a)
{
//read the qam config data
for(i=0;i<8;i++)
{
//read the qam mode
ucMenuQModSubPosition[i]= read_eeprom(0x0011+i);//Q1_MOD_ADDR+i);
//read the ifrequency
ucMenuIFSubPosition[i]=read_eeprom(0x0021+i);//Q1_IF_ADDR+i);
//read symble rate from the eerom
temp=read_eeprom(0x0031+i);//Q1_SMBRAT_ADDR_H+i);
temp1=read_eeprom(0x0041+i);//Q1_SMBRAT_ADDR_L+i);
iSmbRatSaved[i]=temp*100+temp1;
}
//read the com baud
temp=read_eeprom(0x0054);
temp1=read_eeprom(0x0055);
com_set=temp*256+temp1;
//read the sensor temperature alarm value
temperature_h[0]=read_eeprom(S1_TEMP_ADDR_H);
temperature_l[0]=read_eeprom(S1_TEMP_ADDR_L);
temperature_h[1]=read_eeprom(S2_TEMP_ADDR_H);
temperature_l[1]=read_eeprom(S2_TEMP_ADDR_L);
//read the net config
for(i=0;i<4;i++)
{
temp=read_eeprom(NET_GATE+i);
net_gatway[i]=temp;
temp=read_eeprom(NET_SUB+i);
net_sub[i]=temp;
temp= read_eeprom(NET_LIP+i);
net_lip[i]=temp;
temp= read_eeprom(NET_DIP+i);
net_dip[i]=temp;
}
}
else
{
temp=QMODSUBPOSTION_DEFAULT; //qam mode
for(i=0;i<8;i++)
{
write_eeprom(0x0011+i,temp);//Q1_MOD_ADDR+i,temp);
}
temp=1; //ifrequency
for(i=0;i<8;i++)
{
write_eeprom(0x0021+i,temp);//Q1_IF_ADDR+i,temp);
}
for(i=0;i<8;i++)
{
temp=SMBRATESAVED_DEFAULT/100; //symble rate
write_eeprom(0x0031+i,temp);//Q1_SMBRAT_ADDR_H+i,temp);
temp=SMBRATESAVED_DEFAULT%100;
write_eeprom(0x0041+i,temp);
}
//init the Ethernet
net_gatway[0]=10;
net_gatway[1]=0;
net_gatway[2]=0;
net_gatway[3]=205;
net_sub[0]=255;
net_sub[1]=255;
net_sub[2]=255;
net_sub[3]=0;
net_lip[0]=10;
net_lip[1]=0;
net_lip[2]=0;
net_lip[3]=50;
net_dip[0]=10;
net_dip[1]=0;
net_dip[2]=0;
net_dip[3]=211;
for(i=0;i<4;i++)
{
temp=net_gatway[i];
write_eeprom(NET_GATE+i,temp);
temp=net_sub[i];
write_eeprom(NET_SUB+i,temp);
temp=net_lip[i];
write_eeprom(NET_LIP+i,temp);
temp=net_dip[i];
write_eeprom(NET_DIP+i,temp);
}
//init the com baud
temp=COM_BAUD/256;
write_eeprom(0x0054,temp);
temp=read_eeprom(0x0054);
temp=COM_BAUD%256;
write_eeprom(0x0055,temp);
com_set=COM_BAUD;
//init the sensor alarm vaule
temperature_h[0]=40;
temp=40;//S1_TEMP_H_DEFAULT;
write_eeprom(S1_TEMP_ADDR_H,temp);
temperature_l[0]=10;
temp=10;//S1_TEMP_L_DEFAULT;
write_eeprom(S1_TEMP_ADDR_L,temp);
//init the timer
for(i=0;i<7;i++)
time[i]=0;
//init the qam as default value
for(i=0;i<=7;i++)
{
ucMenuIFSubPosition[i]=1;
ucMenuQModSubPosition[i]=QMODSUBPOSTION_DEFAULT;
iSmbRatSaved[i]=SMBRATESAVED_DEFAULT;
}
//init the sound
for(i=0;i<4;i++)
{
temp=1;
write_eeprom(0x005A +i,temp);
}
temp=1;
sound_type_saved=1;
write_eeprom(0x0052,sound_type_saved);
//init the flag of the first power on
temp = 0x5a;
write_eeprom(0x0010,temp);
}
}
//---------------------------------------------------------
// NAME: net_save()
// ENTRY: void
// RETURN: void
// MODIFY: 2004.2.3
//--------------------------------------------------------
void net_save(void)
{
unsigned char temp,i;
SREG&=~0x80;
//set the net
for(i=0;i<4;i++)
{
temp=net_gatway[i];
write_eeprom(NET_GATE+i,temp);
temp=net_sub[i];
write_eeprom(NET_SUB+i,temp);
temp=net_lip[i];
write_eeprom(NET_LIP+i,temp);
temp=net_dip[i];
write_eeprom(NET_DIP+i,temp);
}
SREG|=0x80;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -