微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 51单片机+315M无线射频模块接受程序

51单片机+315M无线射频模块接受程序

时间:11-30 来源:互联网 点击:

#define TEST_PULS(puls_in, puls_type) (puls_in >

//send_string_com("ok",2);
//lcd_reset();
//lcd_power_on();
//lcd_self_test();

while(1){
if (jiffies - last_jiffies >= 20){//每次中断为50us,所以要20次才为1ms
last_jiffies = jiffies;
heart_beat_timer--;
if (send_delay)
send_delay--;
}

if (heart_beat_timer == 0){
heart_beat_timer = HEART_BEAT_INTERVAL;

while(1) {recv();if (recv_stat == RECV_SUCCESS)
{
P0_0=~P0_0;
send_string_com(recv_buf,strlen(recv_buf));
Display_T();
recv_stat = 0;break;}
recv_stat = 0;
}
}

/*#if 0
if (send_stat == 0){
//碰撞测试
START_SEND(8);
send_buf[1]=T;
send_buf[2]=e;
send_buf[3]=s;
send_buf[4]=t;
send_buf[5]=O;
send_buf[6]=k;
send_buf[7]=!;

lcd_out_string("sending:");
//send_string_com(send_buf,strlen(send_buf));
printhex(send_buf[0]);
printhex(send_buf[1]);
}
#endif
*/
wirless();

if (send_stat == SEND_FAILED){

send_stat = 0;

}else if (send_stat == SEND_SUCCESS){
send_stat = 0;
P2_3=~P2_3;

}
//recv();
//send_string_com("start",5);
/*while(1) {recv();if (recv_stat == RECV_SUCCESS)
{
P0_0=~P0_0;
send_string_com(recv_buf,strlen(recv_buf));} }*/
/*if (recv_stat == RECV_SUCCESS){
//send_string_com("test1",5);
#if 1
//unsigned int i;
//for(i=0; i//serial_out(recv_buf[i]);//输出接收到的字符
P0_0=~P0_0;
send_string_com(recv_buf,strlen(recv_buf));
#else
//if (recv_buf[1]==o)
//P0=0x00;
//lcd_out_string("data recived:");
//printhex(recv_buf[0]);
//printhex(recv_buf[1]);
//OutChar();
//send_string_com("test3",5);
#endif
recv_stat = 0;
}
*/
#if 0
if (RI){
unsigned char scmd[17];
heart_beat_timer = HEART_BEAT_INTERVAL;
wait_serial(scmd, 1, 0);
switch(scmd[0]){
case SCMD_RESET:
((void (code *) (void))0x0000) ();//软件复位
case SCMD_SET_PORT:
if (wait_serial(scmd, 2, 200))
break;
switch(scmd[0]){
case 0:
P0 = scmd[1];
break;
case 1:
P1 = scmd[1];
break;
case 2:
P2 = scmd[1];
break;
case 3:
P3 = scmd[1];
break;
}
break;
case SCMD_GET_PORT:
if (wait_serial(scmd, 1, 200))
break;
switch(scmd[0]){
case 0:
serial_out(P0);
break;
case 1:
serial_out(P1);
break;
case 2:
serial_out(P2);
break;
case 3:
serial_out(P3);
break;
}
break;
case SCMD_LCD_OUTSTR:
if (wait_serial(scmd, 1, 200))
break;
scmd[scmd[0]] = 0;
if (wait_serial(scmd, scmd[0], 200))
break;
lcd_out_string(scmd);
break;
case SCMD_LCD_RESET:
lcd_reset();
break;
case SCMD_LCD_CLEAR:
lcd_clear();
break;
case SCMD_LCD_SETXY:
if (wait_serial(scmd, 2, 200))
break;
SetXY(scmd[0], scmd[1]);
break;
case SCMD_LCD_SETLINE:
if (wait_serial(scmd, 1, 200))
break;
SetLine(scmd[0]);
break;
default:
break;
}
}
#endif
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top