初级会员
- 积分
- 88
- 金钱
- 88
- 注册时间
- 2014-1-14
- 在线时间
- 0 小时
|
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> SetRX_Mode(); </div>
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span>if(nRF24L01_RxPacket(RxBuf))</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>{LED1 = 0;</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>if(RxBuf[1] == 1)</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>{<span class="Apple-tab-span" style="white-space:pre;"> </span> <span class="Apple-tab-span" style="white-space:pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> Delay(1000);</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>}LED2 = 0;Delay(1000);</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>if(RxBuf[2] == 1)</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>}<span class="Apple-tab-span" style="white-space:pre;"> <br />
这是<br />
</span>接受段的程序,为什么接收端不管安不安装nrf2401总是跳进if(nRF24L01_RxPacket(RxBuf)),<br />
<br />
<div>unsigned char nRF24L01_RxPacket(unsigned char* rx_buf)</div>
<div>{</div>
<div> unsigned char revale=0;</div>
<div><br />
</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>//SetRX_Mode();</div>
<div><br />
</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>sta=SPI_Read(STATUS);<span class="Apple-tab-span" style="white-space:pre;"> </span>// read register STATUS's value</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>if(RX_DR)<span class="Apple-tab-span" style="white-space:pre;"> </span>// if receive data ready (RX_DR) interrupt</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> CE = 0; </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>SPI_Read_Buf(RD_RX_PLOAD,rx_buf,TX_PLOAD_WIDTH);// read receive payload from RX_FIFO buffer</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>revale =1;//we have receive data</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>SPI_RW_Reg(WRITE_REG+STATUS,sta);// clear RX_DR or TX_DS or MAX_RT interrupt flag</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>return revale;</div>
<div>}</div>
<br />
</div> |
|