1、实验内容 : 实验一 ,实验二,实验六实验一 信息反馈实验while(1)/*用户 14 都报告自己处于摘机状态 */CKReportTE(TE_1, TE_HAND_UP);CKReportTE(TE_2, TE_HAND_UP);CKReportTE(TE_3, TE_HAND_UP);CKReportTE(TE_4, TE_HAND_UP);/*报告超时状态*/CKReportTimeout(1);CKComPrintf(“所有用户都摘机,LCD 显示超时n“);OSTimeDly(500);/*用户 14 都报告自己处于挂机状态 */CKReportTE(TE_1, TE_HAND_D
2、OWN); CKReportTE(TE_2, TE_HAND_DOWN);CKReportTE(TE_3, TE_HAND_DOWN);CKReportTE(TE_4, TE_HAND_DOWN);/*LCD 显示屏上取消 “超时”状态标志*/CKReportTimeout(0);/*LCD 显示屏上报告 “三方”通话状态*/CKReportThreeTel(1);CKComPrintf(“所有用户都挂机,LCD 显示三方n“);OSTimeDly(500);/*用户 14 都报告自己处于振铃状态 */CKReportTE(TE_1, TE_RING);CKReportTE(TE_2, TE_
3、RING);CKReportTE(TE_3, TE_RING);CKReportTE(TE_4, TE_RING);/*LCD 显示屏上取消 “三方”状态标志*/CKReportThreeTel(0);CKComPrintf(“所有用户都振铃,LCD 第四行中央无显示n“);OSTimeDly(500); 实验二 摘挂机检测试验while(1) temp = CheckPickup();temp1 = temp if(temp1 != 0) OSTimeDly(10); / 延时 100 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 != 0)
4、CKReportTE(TE_1, TE_HAND_DOWN); /* 打印调试信息 */CKComPrintf(“用户 1 挂机n“);elseOSTimeDly(10); / 延时 100 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 = 0) CKReportTE(TE_1, TE_HAND_UP); /* 打印调试信息 */CKComPrintf(“用户 1 已经摘机n“);temp1 = temp if(temp1 != 0)/请按照用户 1 的范例填写检测到用户 2 挂机后的确认及报告提示代码OSTimeDly(10); / 延时 1
5、00 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 != 0)CKReportTE(TE_2, TE_HAND_DOWN); /* 打印调试信息 */CKComPrintf(“用户 2 挂机n“);else/请按照用户 1 的范例填写检测到用户 2 摘机后的确认及报告提示代码OSTimeDly(10); / 延时 100 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 = 0)CKReportTE(TE_2, TE_HAND_UP); /* 打印调试信息 */CKComPrintf(“用户 2 已
6、经摘机n“);temp1 = temp if(temp1 != 0)/请按照用户 1 的范例填写检测到用户 3 挂机后的确认及报告提示代码OSTimeDly(10); / 延时 100 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 != 0)CKReportTE(TE_3, TE_HAND_DOWN); /* 打印调试信息 */CKComPrintf(“用户 3 挂机n“);else/请按照用户 1 的范例填写检测到用户 3 摘机后的确认及报告提示代码OSTimeDly(10); / 延时 100 ms 消抖temp = CheckPickup
7、();temp1 = temp if(temp1 = 0)CKReportTE(TE_3, TE_HAND_UP); /* 打印调试信息 */CKComPrintf(“用户 3 已经摘机n“);temp1 = temp if(temp1 != 0)/请按照用户 1 的范例填写检测到用户 4 挂机后的确认及报告提示代码OSTimeDly(10); / 延时 100 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 != 0)CKReportTE(TE_4, TE_HAND_DOWN); /* 打印调试信息 */CKComPrintf(“用户 4 挂机
8、n“);else/请按照用户 1 的范例填写检测到用户 4 摘机后的确认及报告提示代码OSTimeDly(10); / 延时 100 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 = 0)CKReportTE(TE_4, TE_HAND_UP); /* 打印调试信息 */CKComPrintf(“用户 4 已经摘机n“);实验三 空分交换通话试验temp1 = temp if(temp1 != 0) OSTimeDly(20); / 延时 200 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 !
9、= 0) /用户 1 挂机Channel1Status=down;CKReportTE(TE_1, TE_HAND_DOWN); CKComPrintf(“用户 1 已挂机n“);if(Channel3Status=up)DisConnect(CHANNEL1-1+4,CHANNEL3-1+4); /主/被叫硬件断开连接DisConnect(CHANNEL3-1+4,CHANNEL1-1+4); /主/被叫硬件断开连接elseOSTimeDly(20); / 延时 200 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 = 0) /用户 1 摘机
10、Channel1Status=up;CKReportTE(TE_1, TE_HAND_UP); /* 打印调试信息 */if(Channel3Status=up)PortaValue WritePort(RINGRESOUND,PortaValue);PortbValue WritePort(BUSYMUTE_CS,PortbValue);Connect(CHANNEL1-1+4,CHANNEL3-1+4); /主/被叫硬件连接Connect(CHANNEL3-1+4,CHANNEL1-1+4); /主/被叫硬件连接/* 打印调试信息 */CKComPrintf(“用户 1 和用户 3 通话中
11、n“);elseCKComPrintf(“用户 1 已摘机n“);temp1 = temp if(temp1 != 0)OSTimeDly(20); / 延时 200 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 != 0)Channel2Status=down;CKReportTE(TE_2, TE_HAND_DOWN); /* 打印调试信息 */CKComPrintf(“用户 2 已挂机n“);if(Channel4Status=up)DisConnect(CHANNEL2-1+4,CHANNEL4-1+4);/主/被叫硬件断开连接DisC
12、onnect(CHANNEL4-1+4,CHANNEL2-1+4);/主/被叫硬件断开连接elseOSTimeDly(20); / 延时 200 ms 消抖temp = CheckPickup();temp1 = temp if(temp1 = 0)Channel2Status=up;CKReportTE(TE_2, TE_HAND_UP); if(Channel4Status=up)PortaValue WritePort(RINGRESOUND,PortaValue);PortbValue WritePort(BUSYMUTE_CS,PortbValue);Connect(CHANNEL2
13、-1+4,CHANNEL4-1+4); /主/被叫硬件连接Connect(CHANNEL4-1+4,CHANNEL2-1+4); /主/被叫硬件连接/* 打印调试信息 */CKComPrintf(“用户 2 和用户 4 通话中n“);elseCKComPrintf(“用户 2 已摘机n“);void Connect(byte xchannel,byte ychannel)/空分连接WritePort(D8816CTL_CS,0x1);/STB=0,DATA=1WritePort(D8816ADDR_CS,(XCHANNELxchannel3) | ychannel);WritePort(D88
14、16CTL_CS,0x3);/STB=1,DATA=1WritePort(D8816CTL_CS,0x3);/STB=1,DATA=1 WritePort(D8816CTL_CS,0x1);/STB=0,DATA=1void DisConnect(byte xchannel,byte ychannel)/空分撤连WritePort(D8816CTL_CS,0x0);/STB=0,DATA=0WritePort(D8816ADDR_CS,(XCHANNELxchannel3) | ychannel);WritePort(D8816CTL_CS,0x2);/STB=1,DATA=0WritePort(D8816CTL_CS,0x2);/STB=1,DATA=0WritePort(D8816CTL_CS,0x0);/STB=0,DATA=0