nRFBareRadio is a library to use the Radio peripheral in a nRF51 or nRF52 Nordic microcontroller in "bare" mode transmitting raw packets, instead of the usual BLE protocols.

Files at this revision

API Documentation at this revision

Comitter:
fbcosentino
Date:
Fri May 17 14:25:38 2019 +0000
Parent:
0:123cac2364c4
Commit message:
Examples added

Changed in this revision

nRFBareRadio.h Show annotated file Show diff for this revision Revisions of this file
--- a/nRFBareRadio.h	Fri May 17 13:36:56 2019 +0000
+++ b/nRFBareRadio.h	Fri May 17 14:25:38 2019 +0000
@@ -7,6 +7,88 @@
  *  @author Fernando Cosentino
  *  @author Uses some code from a version by Manuel Caballero
  *  (https://os.mbed.com/users/mcm/)
+ *
+ *  Transmitter example:
+ *  @code
+ *  #include "mbed.h"
+ *  #include "nRFBareRadio.h"
+ *
+ *  #ifdef TARGET_NRF52
+ *  DigitalOut led1(P0_17); // nRF52
+ *  #else
+ *  DigitalOut led1(P0_21); // nRF51
+ *  #endif
+ *
+ *  int main(void) {
+ *      int i = 0;
+ *      char buffer[32]; 
+ *
+ *      // Address object
+ *      RadioAddress address = {0xC0, 0x55, 0x42, 0xBB, 0xC2};
+ *
+ *      // Configuration object
+ *      RadioConfig config;
+ *      config.frequency = 10; // 2400 + 10
+ *      // change other config parameters here if you please
+ *   
+ *      // Radio object
+ *      BareRadio radio;
+ *      radio.Setup(RADIO_MODE_TX, address, config); // This is a transmitter
+ *
+ *      // Main loop
+ *      while(1) {
+ *          // Put some data in the buffer     
+ *          sprintf(buffer, "Value = %d\n", i++);
+ *          // Transmit the buffer
+ *          radio.Transmit(buffer);
+ *          // Toggle the LED and wait a bit
+ *          led1 = !led1;
+ *          wait(1.0);
+ *      }
+ *  }
+ *  @endcode
+ *
+ *  Receiver example:
+ *  @code
+ *  #include "mbed.h"
+ *  #include "nRFBareRadio.h"
+ *
+ *  #ifdef TARGET_NRF52
+ *  Serial pc(P0_6, P0_8);  // nRF52
+ *  DigitalOut led1(P0_17); // nRF52
+ *  #else
+ *  Serial pc(P0_9, P0_11); // nRF51
+ *  DigitalOut led1(P0_21); // nRF51
+ *  #endif
+ *
+ *  int main(void) {
+ *      int i = 0;
+ *      char buffer[32]; 
+ *
+ *      // Address object
+ *      RadioAddress address = {0xC0, 0x55, 0x42, 0xBB, 0xC2};
+ *
+ *      // Configuration object
+ *      RadioConfig config;
+ *      config.frequency = 10; // 2400 + 10
+ *      // change other config parameters here if you please
+ *   
+ *      // Radio object
+ *      BareRadio radio;
+ *      radio.Setup(RADIO_MODE_RX, address, config); // This is a receiver
+ *
+ *      // Main loop
+ *      while(1) {
+ *          // Did we receive a packet?
+ *          if (radio.Receive(buffer)) {
+ *              // Print the packet since the transmitter is sending a string
+ *              pc.printf(buffer);
+ *              // Toggle the LED
+ *              led1 = !led1;
+ *          }
+ *      }
+ *  }
+ *  @endcode
  */
 
 #ifndef __NRFBARERADIO
@@ -141,7 +223,7 @@
     void Transmit(unsigned char * data);
     
     /** Checks if a packet was received, and if received fills the supplied
-     *  buffer with the corresponding data. If no packet was received, the
+     *  buffer with the corresponding data. If no packet was received,
      *  the buffer is kept unchanged.
      *
      *  @param data The buffer to be filled as array of char or array of