unsigned char 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 * #
//==============================================================================
//延时10ms
void delay10ms(unsigned int s)
{
unsigned int i;
while(s--)
{
for(i=0;i<9000;i++);
}
}
//==============================================================================
//发送一个字节
void send_byte(unsigned char num)
{
//将num的低5位发送出去,先发低,后发高
unsigned char i;
for(i=0;i<5;i++)
{
if(num&0x01)
{
HT9200_DATA_HIG;
}
else
{
HT9200_DATA_LOW;
}
HT9200_CLK_HIG;
__delay_cycles(40);
HT9200_CLK_LOW;
__delay_cycles(10000);
num>>=1;
}
HT9200_CLK_HIG;
}
//==============================================================================
//拨号
void dial(uint8 *ip)
{
unsigned char num;
CLI();
sys_call_flag =1;
call_pulse_cnt = 0;
while((*ip!=0x20))
{
HT9200_CLK_HIG;
HT9200_CS_LOW;
delay10ms(1);
num = *ip++;
send_byte(table_dtmf[num]);
delay10ms(60); //延时600ms,发送DTMF
HT9200_CS_HIG;
delay10ms(1);
}
HT9200_CS_LOW;
delay10ms(1); //延时10ms,以使其起振
send_byte(0xff);
delay10ms(10); //延时100ms,发送DTMF
HT9200_CS_HIG;
SEI();
} |