📄 main.c
字号:
}
/***************************************
subroutine name: Control_4052
input variable: /
output variable: /
description: selec the point to control the anolog switch.
***************************************/
void Control_4052(void)
{
UNCHAR temp;
temp = SLEC_Point+1;
temp &= 0x03;
switch(temp)
{
case 0:
SLEC_Point= 0;
SWITCH_4052A = 1;
SWITCH_4052B = 0;
break;
case 1:
SLEC_Point= 1;
SWITCH_4052A = 0;
SWITCH_4052B = 1;
break;
case 2:
SLEC_Point= 2;
SWITCH_4052A = 1;
SWITCH_4052B = 1;
break;
case 3:
SLEC_Point= 3;
SWITCH_4052A = 0;
SWITCH_4052B = 0;
break;
default:
break;
}
}
/***************************************
subroutine name: Exchang_CIDData
input variable: EXT_No
output variable: ture or false
description: calculte the data value for dtmf.
***************************************/
BOOL Exchang_CIDData(UNCHAR EXT_No)
{
UNCHAR DtmfTemp;
DtmfTemp= DTMF_Reg_Rec[EXT_No];
if( DtmfTemp == 0 )
{
DTMF_Reg_Rec[EXT_No] = 0x0f;
DtmfTemp = 0x0f;
}
if( DtmfTemp == 0x0a )
{
DTMF_Reg_Rec[EXT_No] = 0;
DtmfTemp = 0;
}
if( DtmfTemp > 9 )
{
return 0;
}
return 1;
}
/***************************************
subroutine name: SendDataToAlign
input variable: channel value
output variable: /
description: send each cid arry value to the align of sending.(include uart arry [16])
***************************************/
void SendDataToAlign(UNCHAR EXT_No)
{
UNCHAR i,temp;
UNINT Addr;
Addr = EXT_No*15;
temp = EXT_RecDtmf_List[Addr] & 0xf0;
if( temp == 0x10 )
{
temp = EXT_RecDtmf_List[Addr] & 0x0f;
MICRO_SendToBuf(ALIGNMENT[WP_ALIGN],
FRAMEHEAD, WP_ALIGN, TAL_ALIGN, ALIGSIZE);
MICRO_SendToBuf(ALIGNMENT[WP_ALIGN],
DISPDATA, WP_ALIGN, TAL_ALIGN, ALIGSIZE);
for( i=1;i<=temp;i++)
{
MICRO_SendToBuf(ALIGNMENT[WP_ALIGN],
EXT_RecDtmf_List[Addr+i], WP_ALIGN, TAL_ALIGN, ALIGSIZE);
}
MICRO_SendToBuf(ALIGNMENT[WP_ALIGN],
FRAMEEND, WP_ALIGN, TAL_ALIGN, ALIGSIZE);
}
else if( temp == 0x30 )
{
MICRO_SendToBuf(ALIGNMENT[WP_ALIGN],
FRAMEHEAD, WP_ALIGN, TAL_ALIGN, ALIGSIZE);
MICRO_SendToBuf(ALIGNMENT[WP_ALIGN],
CLSDATA, WP_ALIGN, TAL_ALIGN, ALIGSIZE);
temp = EXT_RecDtmf_List[Addr] & 0x0f;
for( i=1;i<=temp;i++)
{
MICRO_SendToBuf(ALIGNMENT[WP_ALIGN],
EXT_RecDtmf_List[Addr+i], WP_ALIGN, TAL_ALIGN, ALIGSIZE);
EXT_RecDtmf_List[Addr+i] = 0;
}
EXT_RecDtmf_List[Addr] = 0;
MICRO_SendToBuf(ALIGNMENT[WP_ALIGN],
FRAMEEND, WP_ALIGN, TAL_ALIGN, ALIGSIZE);
}
else
{
EXT_RecDtmf_List[Addr] = 0;
}
}
/***************************************
subroutine name: SendDataToDisp
input variable: /
output variable: /
description: every 5ms send one byte from the align of sending.if no data return,
if wp catch rp return;
***************************************/
void SendDataToDisp(void)
{
UNCHAR temp;
if( TAL_ALIGN )
{
if( WP_ALIGN != RP_ALIGN )
{
MICRO_GetFromBuf(ALIGNMENT[RP_ALIGN],
temp, RP_ALIGN, TAL_ALIGN, ALIGSIZE);
SBUF = temp;
}
}
}
/***************************************
subroutine name: Deal_UartData
input variable: /
output variable: /
description: rec one byte from the uart arry.
***************************************/
void Deal_UartData(void)
{
UNCHAR temp;
if( TAL_UCID)
{
MICRO_GetFromBuf(UART_CIDList[RP_UCID],
temp, RP_UCID, TAL_UCID, ALIGSIZE);
if( Flag_Head )
{
if( Flag_Second )
{
if( temp== 0xaa )
{
Flag_Head = 0;
Flag_Second = 0;
MICRO_SendToBuf(EXT_EVENT_QUEUE[WP_EVENT],
16, WP_EVENT, TAL_EVENT, BUFSIZE);
}
else if( temp>= 0xb0 )
{
temp &= 0x0f;
TRK_No_List[TRK_No*6]++;
if( TRK_No_List[TRK_No*6] >= 6 )
TRK_No_List[TRK_No*6] = 5;
TRK_No_List[TRK_No*6+TRK_No_List[TRK_No*6]] = temp;
}
else
{
EXT_RecDtmf_List[16*15]++;
EXT_RecDtmf_List[16*15+(EXT_RecDtmf_List[16*15]&0x0f)] = temp;
}
}
else
{
if( temp == 0x0a )
{
Flag_Second = 1;
EXT_RecDtmf_List[16*15] = 0x10;
}
else if( temp == 0x0c )
{
Flag_Second = 1;
EXT_RecDtmf_List[16*15] = 0x30;
}
else if( temp == 0x0b )
{
Flag_Second = 1;
EXT_RecDtmf_List[16*15] = 0;
if( TRK_No <= 0x96)
TRK_No ++;
}
else if( temp == 0x0d )
{
Flag_Second = 1;
EXT_RecDtmf_List[16*15] = 0;
TRK_No = 0;
}
else if( temp == 0x0e )
{
Flag_Head = 1;
ISP_Mode = 1;
}
else
{
Flag_Head = 1;
}
}
}
else
{
if( temp==0xcc )
{
Flag_Head = 1;
}
}
}
}
/***************************************
subroutine name: Deal_CIDEvent
input variable: /
output variable: /
description: get the event tal ,then judge the event ,send data to disp align
***************************************/
void Deal_CIDEvent(void)
{
UNCHAR EXT_No;
if( TAL_EVENT )
{
if( Back_Catch_Front(WP_ALIGN, RP_ALIGN, 15) )
{
MICRO_GetFromBuf(EXT_EVENT_QUEUE[RP_EVENT],
EXT_No, RP_EVENT, TAL_EVENT, BUFSIZE);
if( !Deal_TRKNo() )
{
SendDataToAlign(EXT_No);
}
}
}
}
/***************************************
subroutine name: Deal_TRKNo
input variable: /
output variable: true or false
description: get the data from uart,if the data for trk no,must inhabit the data
,or tidy the data and send data to disp align
***************************************/
BOOL Deal_TRKNo(void)
{
UNCHAR i,j;
BOOL Flag_TRK;
Flag_TRK = 0;
for(i=1;i<=TRK_No;i++)
{
for(j=1;j<=(EXT_RecDtmf_List[16*15]&0x0f);j++)
{
if( EXT_RecDtmf_List[16*15+j] == TRK_No_List[i*6+j] )
Flag_TRK = 1;
else
{
Flag_TRK = 0;
break;
}
}
if( Flag_TRK )
return 1;
}
if( !Flag_TRK )
return 0;
}
/***************************************
subroutine name: Catch_WpRpJudge
input variable: front point WP,back point RP,distance size for point.
output variable: bool variable.
description: judge the point for back catch the front point.can catch return fulse
or return true.
***************************************/
BOOL Back_Catch_Front(UNCHAR Back, UNCHAR Front, UNCHAR CatchSize)
{
UNCHAR temp;
temp = Back+CatchSize;
if( Back < Front )
{
if( temp > Front )
{
return TRUE;
}
else if( temp < Front )
{
if( PSW &0x80 )
return FALSE;
else
return TRUE;
}
else
{
return FALSE;
}
}
else if( Back > Front )
{
if( temp < Front )
{
return TRUE;
}
else if( temp > Front )
{
if( PSW &0x80 )
return FALSE;
else
return TRUE;
}
else
{
return FALSE;
}
}
else
{
return TRUE;
}
}
/***************************************
subroutine name: Timer0Int
input variable: /
output variable: /
description:
***************************************/
void Timer0Int(void) interrupt 1
{
#ifdef Timer2ms
LOAD_TIMER0(TimerH_2ms, TimerL_2ms);
Counter2ms++;
Flag_2ms = 0;
if( (Counter2ms/2)&&(!(Counter2ms%2)) )
{
if( RI )
{
RI = 0;
MICRO_SendToBuf(UART_CIDList[WP_UCID],
SBUF, WP_UCID, TAL_UCID, ALIGSIZE);
}
TI = 0;
SendDataToDisp();
}
if( Counter2ms == 3 )
{
Flag_5ms = 0;
}
if( Counter2ms == 6 )
{
Counter2ms = 0;
Counter10ms++;
Flag_10ms = 1;
Flag_5ms = 1;
Flag_Scan = 1;
}
#else
LOAD_TIMER0(TimerH_5ms, TimerL_5ms);
Counter5ms++;
Flag_5ms = 0;
if( RI )
{
RI = 0;
MICRO_SendToBuf(UART_CIDList[WP_UCID],
SBUF, WP_UCID, TAL_UCID, ALIGSIZE);
}
TI = 0;
SendDataToDisp();
if( Counter5ms == 2 )
{
Counter5ms = 0;
Counter10ms++;
Flag_10ms = 1;
Flag_5ms = 1;
Flag_Scan = 1;
}
#endif
if( Counter10ms == 10 )
{
Counter10ms = 0;
Counter100ms++;
Flag_100ms = 1;
}
if( Counter100ms == 2 )
{
Counter100ms = 0;
Flag_s = 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -