电子-4radio.pdf,物联网/通信技术2.4G无线通信packet[o=cNRE RADTO->EVENTS READY aUNRF RADIO->TASKS TXEN 1While(NrF RADIo->EVENTS READY == aU)NRE RADIO->TASKS START 10NRF RADIO->EVENTS END= 0UWhile(NrF RAdIo->EVENTS END = OU)NRE RADIO->EVENTS DISABLED= OU// Disable radioNRE RADIO->TASKS DISABLE 10While(NRF RADIo->EVENTS DISABLED == OU)端(函数请看:int main(void)inito)While(true)// Set payload pointerNRF RADIO->PACKETPTR=(uint32 t)packetNrF RADIO->EVENTS READY U/ Enable radio and wait for readyNRF RADTO->TASKS RXEN 1UWhile(NrF RADIo->EVENTS READY = 0U)NRF RADIO->EVENTS END QUStart listening and wait for address received eventNRF RADIO->TASKS START 10;// Wait for end of packetWhile(NrF RAdIo->EVENTS END== OU)// Write received data to lede and LED1 on Crc matchif (NRF RADIO->CRCSTATUS = 10)switch(packeteD)case 0nrf gpio_pin set(LEDe)nrf_ gpio_ pin clear(LED1);breakcase 1nrf_gpio pin set(LED1);nrf gpio pin clear(ledo)breakNRF RADIO-EVENTS DISABLED = OU;Disable radioNRF RADIO->TASKS DISABLE =10While(NrF radio->EVENTS DISABLED== aU)函数请看:void radio configure()Radio contigNRF RADIO->TXPOWER =(RADIO TXPOWER TXPOWER 0dBm FREQUENCY= 7UL:// Frequency bin 7, 2407MHzNRF RADIO->MODE =(RADIO MODEMODE Nrf 2Mbit < RADIO MODE MODE Pos);// Radio address configNRF RADIO->PREFIXO=0xC4C3C2E7UL; / Prefix byte of addresses 3 to oNRF RADIO->PREFIX1= 0XC5C6C7C8UL; / Prefix byte of addresses 7 to 4NRF RADIO->BASEO 0XE7E7E7E7UL:// Base address for prefix 0NRF RADIO->BASE10X00C2C2C2UL; / Base address for prefix 1-7NRF RADIO->TXADDRESS=0XOBULJ// Set device address e to use whentransmittingNRF RADIO->RXADDRESSES =0X01UL; / Enable device address e to usewhich receiving// Packet configurationNRF RADIO->PCNF0 =(PACKET0 S1 SIZE < RADIO PCNF0 SILEN Pos)PACKETO SO SIZE < RADIO PCNF0 SOLEN Pos)PACKET0 PAYLOAD SIZE < RADIO PCNFB LFLEN Pos),//lint !e845"The right argument to operator ' is certain to be 0"7/ Packet configurationNRF RADIO->PCNF1 =(RADIO PCNF1 WHITEEN Disabled CRCCNF =(RADIO_ CRCCNF_ LEN_ TWO < RADIO CRCCNF LEN_ Pos);//Number of checksum bitsif ((NrF RADIo->CRCCNF RADIO CRCCNF LEN Msk)==(RADIO- CRCCNF LEN TWo< RADIO CRCCNF LEN Pos))NRE RADIO->CRCINTT OXFFFFUL/ Initial valueNRF RADIO-CRCPOLY= 0X11021UL// CRC poly:x^16+×^12^x^5+1else if ((NRF RADIo->CRCCNF RADIO CRCCNF LEN Msk)(RADIO- CRCCNF LEN_ One < RADIO_ CRCCNF_ LEN Pos ))NRF RADIO->CRCINIT = 0XFFULJ/ Initial valueNRE RADIO->CRCPOLY= 0X107UL/ CRC poly:×^8+x^2^×^1+1nrf delay ms(3)演示效果敲击键盘上的或后,串口数据会发送到接收后会回传到串口终端,并且发送无线信号到,板上对应的将会亮起。