?? callid.c
字號:
#define COMMaxByte 32
uchar idata CallIDSum;
uchar idata CallIDFormat;
uchar idata CallidFlag ;
//uchar idata CallIDAccept;
uchar idata CallIDStat;
uchar idata COMBufferLen;
uchar idata COMBuffer[COMMaxByte];
uchar idata ring_time ;
/*****************************************************
撥特率:1200 248個周期(晶振3.5795M) delay 830 us
1200 766個周期(晶振11.0592M)
when call :150 or 189
*****************************************************/
void Fsk_delay(uchar in) //call 1 time + 5
{
uchar i ;
for(i=in;--i;) ; //delay 2*in
}
void callid_open()
{
COMBufferLen = 0 ;
CallIDStat = FALSE ;
CallidFlag = TRUE ;
CallIDFormat = 0xFF;
CallIDSum = 0xFF;
ring_time = 0 ;
PDWN = 0 ;
}
void callid_close()
{
COMBufferLen = 0 ;
CallIDStat = FALSE ;
CallidFlag = FALSE ;
CallIDFormat = 0xFF;
CallIDSum = 0xFF;
// Callid_Ring_time = 0 ;
ring_time = 0 ;
PDWN = 1 ;
}
uchar CallIDStatBit() //check start bit delay 370
{
uchar sample ;
uint i ;
i = 0 ;
sample = 0 ;
while((FSKDIN == 1)||(sample == 0)) //下降沿檢測
{
if((FSKDIN == 1)&&(sample ==0))
sample = 1 ;
if((DV_FSK == 1)||(RING == 0))
{
return 2 ;
}
if(i++ > 60000) return 2 ;
}
Fsk_delay(180) ; //
Fsk_delay(189) ;
Fsk_delay(189) ;
return TRUE ;
}
uchar CallIDReadByte()
{
uchar i,j ;
uchar temp;
temp = 0;
for(i=8;i>0;i--) //830us
{
temp >>= 1;
if(FSKDIN == 1)
temp |= 0x80;
else
j++ ;
Fsk_delay(189) ;
Fsk_delay(189) ;
}
return(temp);
}
uchar CallIDProc()
{
uchar temp ;
uchar temp_r ;
// if(CallidFlag == FALSE) return ERROR ;
StatBitLoop:
// if(CallIDStatBit() != TRUE) goto StatBitLoop ;
temp_r = CallIDStatBit() ;
if(temp_r == TRUE)
temp = CallIDReadByte();
else if(temp_r == 2)
{
return 2 ;
}
else goto StatBitLoop ;
// temp = CallIDReadByte();
if(CallIDStat != TRUE)
{
if((temp == 0x80)||(temp == 0x04))
{
CallIDStat = TRUE ;
CallIDFormat = temp;
CallIDSum = temp;
}
goto StatBitLoop;
}
if(COMBufferLen == COMMaxByte)
{
return ERROR ;
}
if(COMBufferLen == 0)
{
CallIDSum += temp;
COMBuffer[0] = temp;
COMBufferLen++;
}
else if((COMBufferLen-1) == COMBuffer[0])
{
CallIDSum += temp;
if((CallIDSum != 0)||(COMBuffer[0]<8))
{
return ERROR ;
}
else
{
return OK ;
}
}
else
{
temp &= 0x7F;
CallIDSum += temp;
COMBuffer[COMBufferLen++] = temp-0x30;
}
goto StatBitLoop;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -