|
[pre]
bit WaitClrBusy(void)
{unsigned char a;
a=0;
while (a<200)
{a++;
if (BUSY==0) return(1);
delay_time(100);
}
//Зависла шина
XBR0&=0xFE; //Отключить СМБуф
a=0;
while (a<200)
{a++;
SDO=1;SCL=1;
delay_time(100);
SCL=0;
delay_time(100);
SCL=1;
delay_time(100);
if (SDI==1)
{XBR0|=0x01; return(1);}
}
return(0);
}
void SmbInit(void)
{
SMB0CN = 0x00; // SMBus Control Register
SMB0ADR = 0x00; // SMBus Address Register
SMB0CR = 148; // SMBus Clock Rate Register
SMB0DAT=Write;
SMB0CN = 0x40; // SMBus Control Register
XBR0|=0x01;
WaitClrBusy();
}
[/pre]
E-mail: info@telesys.ru