高中生
最后登录1970-1-1
在线时间 小时
注册时间2016-11-29
|
楼主 |
发表于 2017-4-8 22:17:43
|
显示全部楼层
- void Nrf24l01_Init(u8 model, u8 ch)
- {
- SPI_CE_L();
- NRF_Write_Buf(NRF_WRITE_REG+RX_ADDR_P0,RX_ADDRESS,RX_ADR_WIDTH); //D′RX½úμãμØÖ·
- NRF_Write_Buf(NRF_WRITE_REG+TX_ADDR,TX_ADDRESS,TX_ADR_WIDTH); //D′TX½úμãμØÖ·
- NRF_Write_Reg(NRF_WRITE_REG+EN_AA,0x01); //ê1Äüí¨μà0μÄ×Ô¶ˉó|′e
- NRF_Write_Reg(NRF_WRITE_REG+EN_RXADDR,0x01); //ê1Äüí¨μà0μĽóêÕμØÖ·
- NRF_Write_Reg(NRF_WRITE_REG+SETUP_RETR,0x1a); //éèÖÃ×Ô¶ˉÖØ·¢¼ä¸ôê±¼ä:500us;×î′ó×Ô¶ˉÖØ·¢′Îêy:10′Î
- NRF_Write_Reg(NRF_WRITE_REG+RF_CH,ch); //éèÖÃRFí¨μàÎaCHANAL
- NRF_Write_Reg(NRF_WRITE_REG+RF_SETUP,0x0f); //éèÖÃTX·¢éä2Îêy,0dbÔöòæ,2Mbps,μíÔëéùÔöòæ¿aÆô
- //NRF_Write_Reg(NRF_WRITE_REG+RF_SETUP,0x07); //éèÖÃTX·¢éä2Îêy,0dbÔöòæ,1Mbps,μíÔëéùÔöòæ¿aÆô
- /////////////////////////////////////////////////////////
- if(model==1) //RX
- {
- NRF_Write_Reg(NRF_WRITE_REG+RX_PW_P0,RX_PLOAD_WIDTH); //Ñ¡Ôñí¨μà0μÄóDD§êy¾Y¿í¶è
- NRF_Write_Reg(NRF_WRITE_REG + CONFIG, 0x0f); // IRQêÕ·¢íê3éÖD¶Ï¿aÆô,16λCRC,Ö÷½óêÕ
- }
- else if(model==2) //TX
- {
- NRF_Write_Reg(NRF_WRITE_REG+RX_PW_P0,RX_PLOAD_WIDTH); //Ñ¡Ôñí¨μà0μÄóDD§êy¾Y¿í¶è
- NRF_Write_Reg(NRF_WRITE_REG + CONFIG, 0x0e); // IRQêÕ·¢íê3éÖD¶Ï¿aÆô,16λCRC,Ö÷·¢Ëí
- }
- else if(model==3) //RX2
- {
- NRF_Write_Reg(FLUSH_TX,0xff);
- NRF_Write_Reg(FLUSH_RX,0xff);
- NRF_Write_Reg(NRF_WRITE_REG + CONFIG, 0x0f); // IRQêÕ·¢íê3éÖD¶Ï¿aÆô,16λCRC,Ö÷½óêÕ
-
- Spi_RW(0x50);
- Spi_RW(0x73);
- NRF_Write_Reg(NRF_WRITE_REG+0x1c,0x01);
- NRF_Write_Reg(NRF_WRITE_REG+0x1d,0x06);
- }
- else //TX2
- {
- NRF_Write_Reg(NRF_WRITE_REG + CONFIG, 0x0e); // IRQêÕ·¢íê3éÖD¶Ï¿aÆô,16λCRC,Ö÷·¢Ëí
- NRF_Write_Reg(FLUSH_TX,0xff);
- NRF_Write_Reg(FLUSH_RX,0xff);
-
- Spi_RW(0x50);
- Spi_RW(0x73);
- NRF_Write_Reg(NRF_WRITE_REG+0x1c,0x01);
- NRF_Write_Reg(NRF_WRITE_REG+0x1d,0x06);
- }
- SPI_CE_H();
- delay_ms(100);
- }
- //初始化代码
复制代码 |
|