📄 具备跳号跳频和跳址的nrf905的c51演示程序 (ourdev_cn 我们的电子开发社区).htm
字号:
<BR> SystemBuffers.nRFTxBuff[10] = TH0;//
<BR> SystemBuffers.nRFTxBuff[11] = TL0;
<BR> SystemBuffers.nRFTxBuff[12] = SystemBuffers.WaitTime;
<BR> SystemBuffers.nRFTxBuff[13] = SystemBuffers.TimeCount;
<BR> SystemBuffers.nRFTxCount = 32;//主机要求间接无线发送
<BR> }
<BR> else if (SystemBuffers.nRFRxBuff[9] == 0x84) {//子机跳频请求
<BR>// LED3 = 0;//主机跳频灯亮
<BR> SystemBuffers.nRFTxBuff[9] = 0x04;//主机跳频应答
<BR> SystemBuffers.nRFTxBuff[10] = SystemBuffers.nRFTxBuff[8] + 1;//主机跳频
<BR> SystemBuffers.nRFTxCount = 32;//主机要求间接无线发送
<BR> }
<BR> else if (SystemBuffers.nRFRxBuff[9] == 0x03) {//主机变址应答
<BR> LED2 = 0;//子机变址灯亮
<BR> SystemBuffers.nRFRxBuff[0] = SystemBuffers.nRFRxBuff[10];//改写接收地址第1字节
<BR> SystemBuffers.nRFRxBuff[1] = SystemBuffers.nRFRxBuff[11];//改写接收地址第2字节
<BR> SystemBuffers.nRFRxBuff[2] = SystemBuffers.nRFRxBuff[12];//改写接收地址第3字节
<BR> SystemBuffers.nRFRxBuff[3] = SystemBuffers.nRFRxBuff[13];//改写接收地址第4字节
<BR> WritenRFConfig(SystemBuffers.nRFRxBuff);//子机重新配置nRF905接收地址
<BR> }
<BR> else if (SystemBuffers.nRFRxBuff[9] == 0x04) {//主机跳频应答
<BR>// LED3 = 0;//子机跳频灯亮
<BR> SystemBuffers.nRFRxBuff[8] = SystemBuffers.nRFRxBuff[10];
<BR> FastWritenRFConfig(SystemBuffers.nRFRxBuff[8]);//快速配置nRF905,子机跳频
<BR> } <BR> }
<BR> else if (!CD && (SystemBuffers.nRFTxCount == 32)) {//要求间接无线发送(发送命令处理)
<BR> SetTxMode();//设置发送模式
<BR> WriteTXBuffer(SystemBuffers.nRFTxBuff);
<BR> ClrWdt();//清除看门狗计数器
<BR> StartTx();//开始发送
<BR> SystemBuffers.nRFTxCount = 0;//结束发送模式
<BR> if (SystemBuffers.nRFTxBuff[9] == 0x03) {//主机变址应答
<BR><BR> SystemBuffers.nRFRxBuff[4] = SystemBuffers.nRFTxBuff[10];//改写呼叫地址第1字节
<BR> SystemBuffers.nRFRxBuff[5] = SystemBuffers.nRFTxBuff[11];//改写呼叫地址第2字节
<BR> SystemBuffers.nRFRxBuff[6] = SystemBuffers.nRFTxBuff[12];//改写呼叫地址第3字节
<BR> SystemBuffers.nRFRxBuff[7] = SystemBuffers.nRFTxBuff[13];//改写呼叫地址第4字节
<BR> }
<BR><BR> else if (SystemBuffers.nRFTxBuff[9] == 0x04) {//主机跳频应答
<BR> SystemBuffers.nRFRxBuff[8] = SystemBuffers.nRFTxBuff[10];//工作频率低8位
<BR> for (t = 0; t < 2500; t ++);//延时,等待发送结束
<BR> FastWritenRFConfig(SystemBuffers.nRFRxBuff[8]);//快速配置nRF905,主机跳频
<BR> }
<BR> SetRxMode();//设置接收模式 <BR> } <BR>}
<BR><BR>//键 <BR>void Key00(void) using 0 <BR>{
<BR>unsigned char i;
<BR> if (SystemBuffers.nRFTxCount == 0) {//无线发送缓冲区为空
<BR> SystemBuffers.nRFTxBuff[0] = SystemBuffers.nRFRxBuff[4];//呼叫地址第1字节
<BR> SystemBuffers.nRFTxBuff[1] = SystemBuffers.nRFRxBuff[5];//呼叫地址第2字节
<BR> SystemBuffers.nRFTxBuff[2] = SystemBuffers.nRFRxBuff[6];//呼叫地址第3字节
<BR> SystemBuffers.nRFTxBuff[3] = SystemBuffers.nRFRxBuff[7];//呼叫地址第4字节
<BR><BR> SystemBuffers.nRFTxBuff[4] = SystemBuffers.nRFRxBuff[0];//本机地址第1字节
<BR> SystemBuffers.nRFTxBuff[5] = SystemBuffers.nRFRxBuff[1];//本机地址第2字节
<BR> SystemBuffers.nRFTxBuff[6] = SystemBuffers.nRFRxBuff[2];//本机地址第3字节
<BR> SystemBuffers.nRFTxBuff[7] = SystemBuffers.nRFRxBuff[3];//本机地址第4字节
<BR><BR> SystemBuffers.nRFTxBuff[8] = SystemBuffers.nRFRxBuff[8];//工作频率低8位
<BR><BR> SystemBuffers.nRFTxBuff[9] = 0x81;//请求命令
<BR> for (i = 10; i < 32; i ++) SystemBuffers.nRFTxBuff[i] = 0;
<BR> SystemBuffers.nRFTxCount = 32;//要求间接无线发送
<BR> for (i = 0; i < 32; i ++) SioBuffers.SioTxBuff[i] = SystemBuffers.nRFTxBuff[i];
<BR> SioBuffers.SioTXCount = 32;//要求间接串口发送
<BR> TI = 1;//送串口显示
<BR>// LED0 = 0;//压键灯亮 <BR> }
<BR>} <BR><BR>//键 <BR>void Key01(void) using 0 <BR>{
<BR>unsigned char i;
<BR> if (SystemBuffers.nRFTxCount == 0) {//无线发送缓冲区为空
<BR> SystemBuffers.nRFTxBuff[0] = SystemBuffers.nRFRxBuff[4];//呼叫地址第1字节
<BR> SystemBuffers.nRFTxBuff[1] = SystemBuffers.nRFRxBuff[5];//呼叫地址第2字节
<BR> SystemBuffers.nRFTxBuff[2] = SystemBuffers.nRFRxBuff[6];//呼叫地址第3字节
<BR> SystemBuffers.nRFTxBuff[3] = SystemBuffers.nRFRxBuff[7];//呼叫地址第4字节
<BR><BR> SystemBuffers.nRFTxBuff[4] = SystemBuffers.nRFRxBuff[0];//本机地址第1字节
<BR> SystemBuffers.nRFTxBuff[5] = SystemBuffers.nRFRxBuff[1];//本机地址第2字节
<BR> SystemBuffers.nRFTxBuff[6] = SystemBuffers.nRFRxBuff[2];//本机地址第3字节
<BR> SystemBuffers.nRFTxBuff[7] = SystemBuffers.nRFRxBuff[3];//本机地址第4字节
<BR><BR> SystemBuffers.nRFTxBuff[8] = SystemBuffers.nRFRxBuff[8];//工作频率低8位
<BR><BR> SystemBuffers.nRFTxBuff[9] = 0x82;//请求
<BR> for (i = 10; i < 32; i ++) SystemBuffers.nRFTxBuff[i] = 0;
<BR> SystemBuffers.nRFTxCount = 32;//要求间接无线发送
<BR> for (i = 0; i < 32; i ++) SioBuffers.SioTxBuff[i] = SystemBuffers.nRFTxBuff[i];
<BR> SioBuffers.SioTXCount = 32;//要求间接串口发送
<BR> TI = 1;//送串口显示
<BR>// LED1 = 0;//压键灯亮 <BR> } <BR>}
<BR><BR>void Key02(void) using 0 <BR>{
<BR>unsigned char i;
<BR> if (SystemBuffers.nRFTxCount == 0) {//无线发送缓冲区为空
<BR> SystemBuffers.nRFTxBuff[0] = SystemBuffers.nRFRxBuff[4];//呼叫地址第1字节
<BR> SystemBuffers.nRFTxBuff[1] = SystemBuffers.nRFRxBuff[5];//呼叫地址第2字节
<BR> SystemBuffers.nRFTxBuff[2] = SystemBuffers.nRFRxBuff[6];//呼叫地址第3字节
<BR> SystemBuffers.nRFTxBuff[3] = SystemBuffers.nRFRxBuff[7];//呼叫地址第4字节
<BR><BR> SystemBuffers.nRFTxBuff[4] = SystemBuffers.nRFRxBuff[0];//本机地址第1字节
<BR> SystemBuffers.nRFTxBuff[5] = SystemBuffers.nRFRxBuff[1];//本机地址第2字节
<BR> SystemBuffers.nRFTxBuff[6] = SystemBuffers.nRFRxBuff[2];//本机地址第3字节
<BR> SystemBuffers.nRFTxBuff[7] = SystemBuffers.nRFRxBuff[3];//本机地址第4字节
<BR><BR> SystemBuffers.nRFTxBuff[8] = SystemBuffers.nRFRxBuff[8];//工作频率低8位
<BR><BR> SystemBuffers.nRFTxBuff[9] = 0x83;//变址请求
<BR> for (i = 10; i < 32; i ++) SystemBuffers.nRFTxBuff[i] = 0;
<BR> SystemBuffers.nRFTxCount = 32;//要求间接无线发送
<BR> for (i = 0; i < 32; i ++) SioBuffers.SioTxBuff[i] = SystemBuffers.nRFTxBuff[i];
<BR> SioBuffers.SioTXCount = 32;//要求间接串口发送
<BR> TI = 1;//送串口显示
<BR>// LED2 = 0;//压键灯亮 <BR> } <BR>}
<BR><BR>void Key03(void) using 0 <BR>{
<BR>unsigned char i;
<BR> if (SystemBuffers.nRFTxCount == 0) {//无线发送缓冲区为空
<BR> SystemBuffers.nRFTxBuff[0] = SystemBuffers.nRFRxBuff[4];//呼叫地址第1字节
<BR> SystemBuffers.nRFTxBuff[1] = SystemBuffers.nRFRxBuff[5];//呼叫地址第2字节
<BR> SystemBuffers.nRFTxBuff[2] = SystemBuffers.nRFRxBuff[6];//呼叫地址第3字节
<BR> SystemBuffers.nRFTxBuff[3] = SystemBuffers.nRFRxBuff[7];//呼叫地址第4字节
<BR><BR> SystemBuffers.nRFTxBuff[4] = SystemBuffers.nRFRxBuff[0];//本机地址第1字节
<BR> SystemBuffers.nRFTxBuff[5] = SystemBuffers.nRFRxBuff[1];//本机地址第2字节
<BR> SystemBuffers.nRFTxBuff[6] = SystemBuffers.nRFRxBuff[2];//本机地址第3字节
<BR> SystemBuffers.nRFTxBuff[7] = SystemBuffers.nRFRxBuff[3];//本机地址第4字节
<BR><BR> SystemBuffers.nRFTxBuff[8] = SystemBuffers.nRFRxBuff[8];//工作频率低8位
<BR><BR> SystemBuffers.nRFTxBuff[9] = 0x84;//跳频请求
<BR> for (i = 10; i < 32; i ++) SystemBuffers.nRFTxBuff[i] = 0;
<BR> SystemBuffers.nRFTxCount = 32;//要求间接无线发送
<BR> for (i = 0; i < 32; i ++) SioBuffers.SioTxBuff[i] = SystemBuffers.nRFTxBuff[i];
<BR> SioBuffers.SioTXCount = 32;//要求间接串口发送
<BR> TI = 1;//送串口显示
<BR>// LED3 = 0;//压键灯亮 <BR> } <BR>}
<BR><BR>void Key10(void) using 0 <BR>{
<BR> LED0 = 1;//放键灭灯 <BR>}
<BR><BR>void Key11(void) using 0 <BR>{
<BR> LED1 = 1;//放键灭灯 <BR>}
<BR><BR>void Key12(void) using 0 <BR>{
<BR> LED2 = 1;//放键灭灯 <BR>}
<BR><BR>void Key13(void) using 0 <BR>{
<BR> LED3 = 1;//放键灭灯 <BR>}
<BR><BR>void Key20(void) using 0 <BR>{
<BR> LED0 = 1;//长压键灭灯 <BR> Key00();//连发
<BR>} <BR><BR>void Key21(void) using 0 <BR>{
<BR> LED0 = 1;//长压键灭灯 <BR> Key01();//连发
<BR>} <BR><BR>void Key22(void) using 0 <BR>{
<BR> LED0 = 1;//长压键灭灯 <BR> Key02();//连发
<BR>} <BR><BR>void Key23(void) using 0 <BR>{
<BR> LED0 = 1;//长压键灭灯 <BR> Key03();//连发
<BR>}</FONT> </TD></TR>
<TR>
<TD class=f03
style="BORDER-RIGHT: #bbbbbb 0.5pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: #ffffff 0.5pt solid"
vAlign=bottom
bgColor=#d1d9e2>__________________________<BR>__________________________
<BR>╱◥██◣ <BR>|田|田 田| 活在理想中,心在自由飞..........
<BR>╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ </TD></TR>
<TR>
<TD class=f03
style="BORDER-RIGHT: #ffffff 0.5pt solid; BORDER-TOP: medium none; BORDER-LEFT: #bbbbbb 0.5pt solid; BORDER-BOTTOM: #bbbbbb 0.5pt solid"
align=left width="19%" bgColor=#d1d9e2><IMG height=1
src="具备跳号跳频和跳址的nRF905的C51演示程序 (ourdev_cn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -