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.
master.cpp
- Committer:
- sbarzowski
- Date:
- 2017-01-05
- Revision:
- 10:869163c7929d
- Parent:
- 7:e51d0fbb1a25
- Child:
- 27:27cffdb2e9d3
File content as of revision 10:869163c7929d:
#include "common.h" #include "master.h" #include <sstream> int master_loop() { Serial pc(USBTX, USBRX); // tx, rx nRF24L01P radio(PB_15, PB_14, PB_13, PB_12, PB_1, PB_2); // mosi, miso, sck, csn, ce, irq const unsigned long long RX_ADDRESS = MASTER_ADDRESS; const unsigned long long TX_ADDRESS = PIR1_ADDRESS; char rxData[TRANSFER_SIZE]; pc.baud(115200); radio_init(&radio, RX_ADDRESS, TX_ADDRESS); // Display the (default) setup of the nRF24L01+ chip pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", radio.getRfFrequency() ); pc.printf( "nRF24L01+ Output power : %d dBm\r\n", radio.getRfOutputPower() ); pc.printf( "nRF24L01+ Data Rate : %d kbps\r\n", radio.getAirDataRate() ); pc.printf( "nRF24L01+ TX Address : 0x%010llX\r\n", radio.getTxAddress() ); pc.printf( "nRF24L01+ RX0 Address : 0x%010llX\r\n", radio.getRxAddress(NRF24L01P_PIPE_P0) ); pc.printf( "nRF24L01+ RX1 Address : 0x%010llX\r\n", radio.getRxAddress(NRF24L01P_PIPE_P1) ); while (1) { if(radio.readable(NRF24L01P_PIPE_P1)){ int rx_bytes = radio.read(NRF24L01P_PIPE_P1, rxData, sizeof(rxData)); std::stringstream ss; for (int i = 0; i < rx_bytes; ++i) { ss << std::hex << rxData[i] / 16 << rxData[i] % 16; // ugly! } pc.printf("received: %s\r\n", ss.str().c_str()); } } }