初级会员
- 积分
- 163
- 金钱
- 163
- 注册时间
- 2013-11-26
- 在线时间
- 0 小时
|
我现在是两发一收 但是不知道怎么改配置<br />
void TX_Mode(void)<br />
{ <br />
Clr_NRF24L01_CE;<br />
<br />
#if USE_Channel_0 <br />
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+TX_ADDR,(u8*)TX_ADDRESS,TX_ADR_WIDTH); <br />
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+RX_ADDR_P0,(u8*)RX_ADDRESS,RX_ADR_WIDTH);<br />
#elif USE_Channel_1<br />
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+TX_ADDR,(u8*)TX_ADDRESS1,TX_ADR_WIDTH); <br />
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+RX_ADDR_P1,(u8*)RX_ADDRESS1,RX_ADR_WIDTH); <br />
#endif<br />
<br />
<span style="color:#E53333;">nRF24L01_Write_Reg(NRF24L01_WRITE_REG+EN_AA,0X01);</span><br />
<span style="color:#E53333;"> nRF24L01_Write_Reg(NRF24L01_WRITE_REG+EN_RXADDR,0x01);</span><br />
<br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+SETUP_RETR,0x1a);<br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RF_CH,50); <br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RF_SETUP,0x0f); <br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+CONFIG,0x0e); <br />
Set_NRF24L01_CE; <br />
} <br />
<br />
<br />
void RX_Mode(void)<br />
{<br />
Clr_NRF24L01_CE; <br />
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+RX_ADDR_P0,(u8*)RX_ADDRESS,RX_ADR_WIDTH);<br />
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+RX_ADDR_P1,(u8*)RX_ADDRESS1,RX_ADR_WIDTH);<br />
<br />
<span style="color:#E53333;">nRF24L01_Write_Reg(NRF24L01_WRITE_REG+EN_AA,0X03);</span><span style="color:#E53333;"></span><br />
<span style="color:#E53333;"> nRF24L01_Write_Reg(NRF24L01_WRITE_REG+EN_RXADDR,0x03); </span><br />
<br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RF_CH,50); <br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RX_PW_P0,RX_PLOAD_WIDTH); <br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RX_PW_P1,RX_PLOAD_WIDTH);<br />
<br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RF_SETUP,0x0f); <br />
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+CONFIG, 0x0f);<br />
Set_NRF24L01_CE; <br />
} <br />
<br />
<span style="font-size:14px;color:#009900;">我在红色部分改动了 接收是0x03 打开0、1通道 发送是0x01</span><span style="font-size:14px;color:#009900;">打开0通道(</span><span style="font-size:14px;color:#009900;">0x02打开1通道)</span><br />
<span style="font-size:14px;color:#009900;">不知道我这样配置有没有错误 不论我怎么改感觉都是0通道接收 就大神指导<br />
<br />
<span style="color:#000000;">u8 nRF24L01_RxPacket(u8 *rxbuf)</span><br />
<span style="color:#000000;"> {</span><br />
<span style="color:#000000;"> u8 RX_P_NO;</span><br />
<span style="color:#000000;"> u8 sta; </span><br />
<span style="color:#000000;"> sta=nRF24L01_Read_Reg(STATUS); </span><br />
<span style="color:#000000;"> nRF24L01_Write_Reg(NRF24L01_WRITE_REG+STATUS,sta); </span><br />
<span style="color:#000000;"> if(sta&RX_OK)</span><br />
<span style="color:#000000;"> {</span><br />
RX_P_NO=sta&0x0e;<br />
switch(RX_P_NO)<br />
{<br />
case 0x00: nRF24L01_Read_Buf(NRF24L01_RD_RX_PLOAD,rxbuf,RX_PLOAD_WIDTH);<br />
printf(" channel 0\r\n");<br />
break;<br />
<br />
case 0x02: nRF24L01_Read_Buf(NRF24L01_RD_RX_PLOAD,rxbuf,RX_PLOAD_WIDTH);<br />
printf(" channel 1\r\n");<br />
break;<br />
<br />
<br />
default: break;<br />
<span style="color:#000000;">} </span><br />
<span style="color:#000000;"> nRF24L01_Write_Reg(NRF24L01_FLUSH_RX,0xff);//????RX FIFO?????÷ </span><br />
<span style="color:#000000;"> return 0; </span><br />
<span style="color:#000000;"> } </span><br />
<span style="color:#000000;"> return 1;<br />
}</span><br />
<span style="color:#000000;"></span></span><span style="font-size:14px;color:#009900;">这个接收的通道选择对不对啊 </span><br />
<br /> |
|