📄 rf2401_test.c
字号:
/****************************************************************************
** - RF2401_TEST.c -
**
** ERC-RF2401A无线收发模块测试板代码
**
** 芯片型号 : NORDIC公司 nRF2401 ATmega48
**
** IDE类型 : IAR
**
** 杭州ERC实验室
**
***************************************************************************/
#include"RF2401_TEST.h"
unsigned char pack_receive[28];
unsigned char pack_sent[28];
void main()
{
unsigned char temp;
KEY1_DDR = 0;
KEY2_DDR = 0;
KEY1 = 1;
KEY2 = 1;
LED1_DDR = 1;
LED2_DDR = 1;
nRF2401AInitializtion();
pack_sent[0] = 1;
pack_sent[27] = 1;
LED1 = 1;
LED2 = 1;
for(temp=0;temp<250;temp++)
{nRF2401APrintf(pack_sent);}
LED1 = 0;
LED2 = 0;
while(1)
{
if(KEY1_PIN==0 && KEY2_PIN==1)
{
pack_sent[0] = 1;
pack_sent[27] = 0;
LED1 = 1;
LED2 = 0;
nRF2401APrintf(pack_sent);
LED1 = 0;
LED2 = 0;
}
if(KEY1_PIN==1 && KEY2_PIN==0)
{
pack_sent[0] = 0;
pack_sent[27] = 1;
LED1 = 0;
LED2 = 1;
nRF2401APrintf(pack_sent);
LED1 = 0;
LED2 = 0;
}
if(KEY1_PIN==0 && KEY2_PIN==0)
{
pack_sent[0] = 1;
pack_sent[27] = 1;
LED1 = 1;
LED2 = 1;
nRF2401APrintf(pack_sent);
LED1 = 0;
LED2 = 0;
}
if(nRF2401AScanf(pack_receive)==1)
{
if(pack_receive[0]==1)
LED1 = 1;
else
LED1 = 0;
if(pack_receive[27]==1)
LED2 = 1;
else
LED2 = 0;
for(unsigned char time=0; time<30; time++)
{
for(unsigned char i=0; i<250; i++);
}//延迟3毫秒
LED1 = 0;
LED2 = 0;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -