我现在是两发一收 但是不知道怎么改配置
void TX_Mode(void)
{
Clr_NRF24L01_CE;
#if USE_Channel_0
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+TX_ADDR,(u8*)TX_ADDRESS,TX_ADR_WIDTH);
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+RX_ADDR_P0,(u8*)RX_ADDRESS,RX_ADR_WIDTH);
#elif USE_Channel_1
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+TX_ADDR,(u8*)TX_ADDRESS1,TX_ADR_WIDTH);
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+RX_ADDR_P1,(u8*)RX_ADDRESS1,RX_ADR_WIDTH);
#endif
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+EN_AA,0X01);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+EN_RXADDR,0x01);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+SETUP_RETR,0x1a);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RF_CH,50);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RF_SETUP,0x0f);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+CONFIG,0x0e);
Set_NRF24L01_CE;
}
void RX_Mode(void)
{
Clr_NRF24L01_CE;
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+RX_ADDR_P0,(u8*)RX_ADDRESS,RX_ADR_WIDTH);
nRF24L01_Write_Buf(NRF24L01_WRITE_REG+RX_ADDR_P1,(u8*)RX_ADDRESS1,RX_ADR_WIDTH);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+EN_AA,0X03);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+EN_RXADDR,0x03);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RF_CH,50);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RX_PW_P0,RX_PLOAD_WIDTH);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RX_PW_P1,RX_PLOAD_WIDTH);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+RF_SETUP,0x0f);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+CONFIG, 0x0f);
Set_NRF24L01_CE;
}
我在红色部分改动了 接收是0x03 打开0、1通道 发送是0x01打开0通道(0x02打开1通道)
不知道我这样配置有没有错误 不论我怎么改感觉都是0通道接收 就大神指导
u8 nRF24L01_RxPacket(u8 *rxbuf)
{
u8 RX_P_NO;
u8 sta;
sta=nRF24L01_Read_Reg(STATUS);
nRF24L01_Write_Reg(NRF24L01_WRITE_REG+STATUS,sta);
if(sta&RX_OK)
{
RX_P_NO=sta&0x0e;
switch(RX_P_NO)
{
case 0x00: nRF24L01_Read_Buf(NRF24L01_RD_RX_PLOAD,rxbuf,RX_PLOAD_WIDTH);
printf(" channel 0rn");
break;
case 0x02: nRF24L01_Read_Buf(NRF24L01_RD_RX_PLOAD,rxbuf,RX_PLOAD_WIDTH);
printf(" channel 1rn");
break;
default: break;
}
nRF24L01_Write_Reg(NRF24L01_FLUSH_RX,0xff);//????RX FIFO?????÷
return 0;
}
return 1;
}
这个接收的通道选择对不对啊