📄 8810.c
字号:
/********************************************
ht9200/ht9170程序
双音多频接收发射驱动程序
********************************************/
#include "stc89c52.h"
#include "12232.h"
#include <intrins.h>
#include "8810.h"
sbit CE = P2^3 ;
sbit DATA = P2^4 ;
sbit CLK = P2^5 ;
sbit RING = P2^2 ;
sbit SW = P2^1 ;
#define uchar unsigned char
#define uint unsigned int
uchar code Table_DTMF[] = {0x0a,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0d,0x0e,0x0f,0x00,0x0b,0x0c} ;
// 0 1 2 3 4 5 6 7 8 9 A B C D * #
/*************************************************
Name :send_ht9200
Describ :发送一个DTMF
Input :in : 要发送的DTMF(0x00-0x0f)
Output :无
Writer :孙福朋 2004.10.5
*************************************************/
void time(uint delaytime)
{
while(--delaytime);
}
void send_ht9200(uchar in)
{
uchar i ;
CLK = 1 ;
CE = 0 ; //使能HT9200,开始起振
Delay(20) ; //延时20MS 保证HT9200起振时间
//EA = 0 ; //关中断
in = Table_DTMF[in] ; //取真正要发送的数值
for(i=0;i<5;i++) //循环传送5位
{
if(((in>>i)&0x01) == 1) //取低位
DATA = 1 ;
else DATA = 0 ;
time(14) ; //延时30US 保证时钟宽度
CLK = 0 ; //时钟下降延锁存数据
time(14) ; //延时30US 保证时钟宽度
CLK = 1 ; //时钟恢复
}
DATA = 1 ;
//EA = 1 ; //开中断
Delay(120) ; //延时130MS,保证DTMF发出有一定时间的波形
CE = 1 ; //关使能,停止起振
}
/*************************************************
Name :check_Init
Describ :初始化 检测程序中用到的端口和变量
Input :无
Output :无
Writer :孙福朋 2004.10.5
*************************************************/
void check_Init()
{
//D0 = 1 ;
//D1 = 1 ;
//D2 = 1 ;
//D3 = 1 ;
//DV = 1 ;
//OE = 0 ;
CE = 1 ;
CLK = 1 ;
DATA = 1 ;
//Check0 = 1 ; //初值为振铃无效时的状态,振铃为低有效
//Counter0 = 20 ;
//Check1 = 0 ; //初值为DV无效时的状态,DV为高有效
//Counter1 = 20 ;
//Check_DX_Counter = 0 ;
//Check_DX_Counter1 = 0 ;
//Check_DX_flag = 0 ;
//CheckDxFlag = 0 ;
//Is_CheckDxFlag = 0 ;
}
//拨11位手机函数
extern void BoHao11(unsigned char N1,unsigned char N2,unsigned char N3,unsigned char N4,unsigned char N5,
unsigned char N6,unsigned char N7,unsigned char N8,unsigned char N9,unsigned char N10,unsigned char N11)
{
SW=0;SW=0;Delay(500);
SW=1;SW=1;Delay(500);
send_ht9200(N1);Delay(50);
send_ht9200(N2);Delay(50);
send_ht9200(N3);Delay(50);
send_ht9200(N4);Delay(50);
send_ht9200(N5);Delay(50);
send_ht9200(N6);Delay(50);
send_ht9200(N7);Delay(50);
send_ht9200(N8);Delay(50);
send_ht9200(N9);Delay(50);
send_ht9200(N10);Delay(50);
send_ht9200(N11);Delay(50);
}
//拨8位电话函数
extern void BoHao8(unsigned char N1,unsigned char N2,unsigned char N3,unsigned char N4,unsigned char N5,
unsigned char N6,unsigned char N7,unsigned char N8)
{
SW=0;SW=0;Delay(500);
SW=1;SW=1;Delay(500);
send_ht9200(N1);Delay(50);
send_ht9200(N2);Delay(50);
send_ht9200(N3);Delay(50);
send_ht9200(N4);Delay(50);
send_ht9200(N5);Delay(50);
send_ht9200(N6);Delay(50);
send_ht9200(N7);Delay(50);
send_ht9200(N8);Delay(50);
}
//拨8位电话函数
extern void BoHao7(unsigned char N1,unsigned char N2,unsigned char N3,unsigned char N4,unsigned char N5,
unsigned char N6,unsigned char N7)
{
SW=0;SW=0;Delay(500);
SW=1;SW=1;Delay(500);
send_ht9200(N1);Delay(50);
send_ht9200(N2);Delay(50);
send_ht9200(N3);Delay(50);
send_ht9200(N4);Delay(50);
send_ht9200(N5);Delay(50);
send_ht9200(N6);Delay(50);
send_ht9200(N7);Delay(50);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -