📄 main.c.bak
字号:
send_data_by_RF(RF_DATA_PACKET_SIZE); // 发送应答
Clr_Screen = 1; // 设置更新屏幕标志位
TF0 = 0;
TH0 = 0x94;
TL0 = 0x00; // (65536 - 37888(0x9400))*12/33.177 = 10ms
Timer0_Cnt = 20; // 准备延时200ms后返回到主屏显示
TR0 = 1; // enable timer0
}
else if(Rf_Rec_Buf[0] == RF_UP_CMD) // 是否为子机返回的数据
{
if(Wait_Ack) // 是否在等待应答状态
{
for(i=2; i<RF_DATA_PACKET_SIZE-1; i++)
{
if(Rf_Rec_Buf[i] != Rf_Send_Buf[i]) // 判断接收到的应答是否有错
{
return_ack = 0;
break;
}
}
if(return_ack) // 应答正确
{
lcd_printf_string("Succeed ", ROW(0x00)|LEN(0x08)|COL(0x00)); // 显示通信成功
lcd_printf_string(" ", ROW(0x01)|LEN(0x08)|COL(0x00));
Wait_Ack = 0;
Clr_Screen = 1; // 设置更新屏幕标志位
TF0 = 0;
TH0 = 0x94;
TL0 = 0x00; // (65536 - 37888(0x9400))*12/33.177 = 10ms
Timer0_Cnt = 40; // 准备延时400ms后返回到主屏显示
TR0 = 1; // enable timer0
}
}
}
}
/**********************************************************
name: display_rf_channel
input: none
output: none
describe: 显示RF当前的channel
notice:
creat date: 2008-8-7
creator: dengyihong
**********************************************************/
void display_rf_channel(void)
{
switch(Rf_Channel_Cnt)
{
case 0:
lcd_printf_string(" 2.400G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 1:
lcd_printf_string(" 2.404G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 2:
lcd_printf_string(" 2.408G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 3:
lcd_printf_string(" 2.412G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 4:
lcd_printf_string(" 2.416G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 5:
lcd_printf_string(" 2.420G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 6:
lcd_printf_string(" 2.424G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 7:
lcd_printf_string(" 2.428G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 8:
lcd_printf_string(" 2.432G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 9:
lcd_printf_string(" 2.436G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 10:
lcd_printf_string(" 2.440G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 11:
lcd_printf_string(" 2.444G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 12:
lcd_printf_string(" 2.448G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 13:
lcd_printf_string(" 2.452G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 14:
lcd_printf_string(" 2.456G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 15:
lcd_printf_string(" 2.460G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 16:
lcd_printf_string(" 2.464G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 17:
lcd_printf_string(" 2.468G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 18:
lcd_printf_string(" 2.472G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 19:
lcd_printf_string(" 2.476G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 20:
lcd_printf_string(" 2.480G ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
default:
break;
}
}
/**********************************************************
name: display_rf_fdev
input: none
output: none
describe: 显示RF当前的频偏
notice:
creat date: 2008-8-7
creator: dengyihong
**********************************************************/
void display_rf_fdev(void)
{
switch(Rf_Fdev_Cnt)
{
case 0:
lcd_printf_string(" 31K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 1:
lcd_printf_string(" 46K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 2:
lcd_printf_string(" 62K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 3:
lcd_printf_string(" 80K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 4:
lcd_printf_string(" 108K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 5:
lcd_printf_string(" 124K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 6:
lcd_printf_string(" 155K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 7:
lcd_printf_string(" 186K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 8:
lcd_printf_string(" 200K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 9:
lcd_printf_string(" 248K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 10:
lcd_printf_string(" 294K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 11:
lcd_printf_string(" 400K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
default:
break;
}
}
/**********************************************************
name: display_rf_rate
input: none
output: none
describe: 显示RF当前的rate
notice:
creat date: 2008-8-7
creator: dengyihong
**********************************************************/
void display_rf_rate(void)
{
switch(Rf_Rate_Cnt)
{
case 0:
lcd_printf_string(" 25K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 1:
lcd_printf_string(" 50K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 2:
lcd_printf_string(" 62.5K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 3:
lcd_printf_string(" 100K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 4:
lcd_printf_string(" 125K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 5:
lcd_printf_string(" 250K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
case 6:
lcd_printf_string(" 500K ", ROW(0x01)|LEN(0x08)|COL(0x00));
break;
default:
break;
}
}
/**********************************************************
name: send_test_data
input: none
output: none
describe: 发送测试数据,供测试发射参数
notice: 只有在发送状态才调用此函数
creat date: 2008-8-11
creator: dengyihong
**********************************************************/
void send_parmeter_test(void)
{
U8 i = 0;
if(Rf_Mode_Cnt == SEND_STATUS)
{
Rf_Send_Buf[0] = RF_TEST_CMD;
Rf_Send_Buf[1] = 0x08;
for(i=2; i<RF_DATA_PACKET_SIZE-1; i++)
{
Rf_Send_Buf[i] = rand();
}
Rf_Send_Buf[i] = 0xaa;
send_test_data_by_RF(RF_DATA_PACKET_SIZE); // 发送测试数据
}
}
/**********************************************************
name: int0_isr
input: none
output: none
describe: int0 中断处理
notice:
creat date: 2008-7-24
creator: dengyihong
**********************************************************/
void int0_isr() interrupt 0 using 1
{
}
/**********************************************************
name: int1_isr
input: none
output: none
describe: int1 中断处理
notice: 接收RF数据
creat date: 2008-7-24
creator: dengyihong
**********************************************************/
void int1_isr() interrupt 2 using 1
{
}
/**********************************************************
name: timer0_isr
input: none
output: none
describe: timer0 中断处理
notice:
creat date: 2008-7-24
creator: dengyihong
**********************************************************/
void timer0_isr() interrupt 1 using 1
{
}
/**********************************************************
name: dispose_timer0
input: none
output: none
describe: 处理定时器0
notice:
creat date: 2008-7-24
creator: dengyihong
**********************************************************/
void dispose_timer0(void)
{
if(TF0)
{
TF0 = 0;
TH0 = 0x94;
TL0 = 0x00; // 定时10ms
if(Wait_Ack) // 是否在等待应答
{
Timer0_Cnt--;
if(Timer0_Cnt)
{
}
else // 在设置的时间内如果没有收到应答就显示错误
{
Wait_Ack = 0;
lcd_printf_string("Failure ", ROW(0x00)|LEN(0x08)|COL(0x00));
lcd_printf_string(" ", ROW(0x01)|LEN(0x08)|COL(0x00));
Clr_Screen = 1; // 设置更新屏幕标志位
TF0 = 0;
TH0 = 0x94;
TL0 = 0x00; // (65536 - 37888(0x9400))*12/33.177 = 10ms
Timer0_Cnt = 40; // 延时400ms后返回到主屏显示
TR0 = 1; // enable timer0
}
}
else if(Clr_Screen)
{
Timer0_Cnt--;
if(Timer0_Cnt)
{
}
else // 延时时间到,返回到主屏显示
{
TR0 = 0; // disable timer0
Clr_Screen = 0;
lcd_printf_string("COOLWAVE", ROW(0x00)|LEN(0x08)|COL(0x00));
lcd_printf_string(" A7105 ", ROW(0x01)|LEN(0x08)|COL(0x00));
}
}
}
}
/**********************************************************
name: timer1_isr
input: none
output: none
describe: timer1 中断处理
notice:
creat date: 2008-7-24
creator: dengyihong
**********************************************************/
void timer1_isr() interrupt 3 using 1
{
}
/**********************************************************
name: uart_rx_isr
input: none
output: none
describe: uart 接收中断处理
notice: 从uart接收1byte 的数据
creat date: 2008-7-24
creator: dengyihong
**********************************************************/
void uart_rx_isr() interrupt 4 using 1
{
}
/**********************************************************
name: delay_2us
input: delay_cnt
output: none
describe: delay x*2us
notice:
creat date: 2008-7-24
creator: dengyihong
**********************************************************/
void delay_2us(U16 delay_cnt)
{
while(delay_cnt--);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -