Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of kl25Z_nRF_RX by
Receiver.cpp
00001 #include "mbed.h" 00002 #include "nRF24L01P.h" 00003 00004 Serial pc(USBTX, USBRX); // tx, rx 00005 00006 nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4); // mosi, miso, sck, csn, ce, irq 00007 DigitalOut GreenLED(PTA12); 00008 00009 00010 int main() { 00011 00012 char count[2]; 00013 char RxDataCnt; 00014 char temp; 00015 00016 my_nrf24l01p.powerUp(); 00017 my_nrf24l01p.setRfFrequency(2410); 00018 00019 // Display the (default) setup of the nRF24L01+ chip 00020 pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", my_nrf24l01p.getRfFrequency() ); 00021 pc.printf( "nRF24L01+ Output power : %d dBm\r\n", my_nrf24l01p.getRfOutputPower() ); 00022 pc.printf( "nRF24L01+ Data Rate : %d kbps\r\n", my_nrf24l01p.getAirDataRate() ); 00023 pc.printf( "nRF24L01+ TX Address : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() ); 00024 pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() ); 00025 00026 pc.printf( "Simple 2 Byte Receiver\r\n" ); 00027 00028 RxDataCnt = 2; 00029 my_nrf24l01p.setTransferSize( RxDataCnt ); 00030 00031 my_nrf24l01p.setReceiveMode(); 00032 my_nrf24l01p.enable(); 00033 00034 while (1) { 00035 00036 // If we've received anything in the nRF24L01+... 00037 if ( my_nrf24l01p.readable() ) { 00038 00039 // ...read the data into the receive buffer 00040 temp = my_nrf24l01p.read( NRF24L01P_PIPE_P0, count, RxDataCnt ); 00041 00042 00043 pc.printf( "Cnt %d = %d %d\r\n",temp,count[0],count[1]); 00044 00045 00046 // Toggle LED2 (to help debug nRF24L01+ -> Host communication) 00047 GreenLED = !GreenLED; 00048 wait_ms(10); 00049 } 00050 } 00051 }
Generated on Wed Jul 13 2022 10:19:54 by
1.7.2
