diff --git a/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino b/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino index 8a5b6e16..8b28f205 100644 --- a/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino +++ b/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino @@ -29,6 +29,9 @@ SX1262 radio = new Module(10, 2, 3, 9); // https://github.com/jgromes/RadioShield //SX1262 radio = RadioShield.ModuleA; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + void setup() { Serial.begin(9600); diff --git a/examples/SX126x/SX126x_Channel_Activity_Detection_Interrupt/SX126x_Channel_Activity_Detection_Interrupt.ino b/examples/SX126x/SX126x_Channel_Activity_Detection_Interrupt/SX126x_Channel_Activity_Detection_Interrupt.ino index 2598e68c..ed658daa 100644 --- a/examples/SX126x/SX126x_Channel_Activity_Detection_Interrupt/SX126x_Channel_Activity_Detection_Interrupt.ino +++ b/examples/SX126x/SX126x_Channel_Activity_Detection_Interrupt/SX126x_Channel_Activity_Detection_Interrupt.ino @@ -29,6 +29,9 @@ SX1262 radio = new Module(10, 2, 3, 9); // https://github.com/jgromes/RadioShield //SX1262 radio = RadioShield.ModuleA; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + void setup() { Serial.begin(9600); diff --git a/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino b/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino index 7231da00..d3b910db 100644 --- a/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino +++ b/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino @@ -30,6 +30,9 @@ SX1262 radio = new Module(10, 2, 3, 9); // https://github.com/jgromes/RadioShield //SX1262 radio = RadioShield.ModuleA; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + void setup() { Serial.begin(9600); diff --git a/examples/SX126x/SX126x_PingPong/SX126x_PingPong.ino b/examples/SX126x/SX126x_PingPong/SX126x_PingPong.ino index 1f0f8688..30c1550b 100644 --- a/examples/SX126x/SX126x_PingPong/SX126x_PingPong.ino +++ b/examples/SX126x/SX126x_PingPong/SX126x_PingPong.ino @@ -26,6 +26,9 @@ SX1262 radio = new Module(10, 2, 3, 9); // https://github.com/jgromes/RadioShield //SX1262 radio = RadioShield.ModuleA; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + // save transmission states between loops int transmissionState = RADIOLIB_ERR_NONE; @@ -105,17 +108,17 @@ void loop() { if (transmissionState == RADIOLIB_ERR_NONE) { // packet was successfully sent Serial.println(F("transmission finished!")); - + } else { Serial.print(F("failed, code ")); Serial.println(transmissionState); - + } // listen for response radio.startReceive(); transmitFlag = false; - + } else { // the previous operation was reception // print data and send another packet @@ -125,21 +128,21 @@ void loop() { if (state == RADIOLIB_ERR_NONE) { // packet was successfully received Serial.println(F("[SX1262] Received packet!")); - + // print data of the packet Serial.print(F("[SX1262] Data:\t\t")); Serial.println(str); - + // print RSSI (Received Signal Strength Indicator) Serial.print(F("[SX1262] RSSI:\t\t")); Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); - + // print SNR (Signal-to-Noise Ratio) Serial.print(F("[SX1262] SNR:\t\t")); Serial.print(radio.getSNR()); Serial.println(F(" dB")); - + } // wait a second before transmitting again @@ -154,6 +157,6 @@ void loop() { // we're ready to process more packets, // enable interrupt service routine enableInterrupt = true; - + } } diff --git a/examples/SX126x/SX126x_Receive/SX126x_Receive.ino b/examples/SX126x/SX126x_Receive/SX126x_Receive.ino index 0c862e69..364509ea 100644 --- a/examples/SX126x/SX126x_Receive/SX126x_Receive.ino +++ b/examples/SX126x/SX126x_Receive/SX126x_Receive.ino @@ -34,6 +34,9 @@ SX1262 radio = new Module(10, 2, 3, 9); // https://github.com/jgromes/RadioShield //SX1262 radio = RadioShield.ModuleA; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + void setup() { Serial.begin(9600); diff --git a/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino b/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino index 2a732d91..d50f2849 100644 --- a/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino +++ b/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino @@ -35,6 +35,9 @@ SX1262 radio = new Module(10, 2, 3, 9); // https://github.com/jgromes/RadioShield //SX1262 radio = RadioShield.ModuleA; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + void setup() { Serial.begin(9600); diff --git a/examples/SX126x/SX126x_Settings/SX126x_Settings.ino b/examples/SX126x/SX126x_Settings/SX126x_Settings.ino index f33c9aa0..b601ae18 100644 --- a/examples/SX126x/SX126x_Settings/SX126x_Settings.ino +++ b/examples/SX126x/SX126x_Settings/SX126x_Settings.ino @@ -45,6 +45,9 @@ SX1268 radio2 = new Module(8, 4, 5, 6); // https://github.com/jgromes/RadioShield //SX1261 radio3 = RadioShield.ModuleB; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + void setup() { Serial.begin(9600); diff --git a/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino b/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino index 5b4c5d0d..c4857e2a 100644 --- a/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino +++ b/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino @@ -30,6 +30,9 @@ SX1262 radio = new Module(10, 2, 3, 9); // https://github.com/jgromes/RadioShield //SX1262 radio = RadioShield.ModuleA; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + void setup() { Serial.begin(9600); diff --git a/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino b/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino index 0ec70f65..19e76817 100644 --- a/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino +++ b/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino @@ -31,6 +31,9 @@ SX1262 radio = new Module(10, 2, 3, 9); // https://github.com/jgromes/RadioShield //SX1262 radio = RadioShield.ModuleA; +// or using CubeCell +//SX1262 radio = new Module(RADIOLIB_ONBOARD_MODULE); + // save transmission state between loops int transmissionState = RADIOLIB_ERR_NONE; diff --git a/keywords.txt b/keywords.txt index e29eece1..7b86be5d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -234,6 +234,8 @@ RADIOLIB_ENCODING_NRZ LITERAL1 RADIOLIB_ENCODING_MANCHESTER LITERAL1 RADIOLIB_ENCODING_WHITENING LITERAL1 +RADIOLIB_BUILTIN_MODULE LITERAL1 + RADIOLIB_ERR_NONE LITERAL1 RADIOLIB_ERR_UNKNOWN LITERAL1 diff --git a/src/BuildOpt.h b/src/BuildOpt.h index e0924c94..e5221e5d 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -27,6 +27,7 @@ * RADIOLIB_NONVOLATILE_READ_BYTE - function/macro to read variables saved in program storage (usually Flash). * RADIOLIB_TYPE_ALIAS - construct to create an alias for a type, usually vai the `using` keyword. * RADIOLIB_TONE_UNSUPPORTED - some platforms do not have tone()/noTone(), which is required for AFSK. + * RADIOLIB_BUILTIN_MODULE - some platforms have a builtin radio module on fixed pins, this macro is used to specify that pinout. * * In addition, some platforms may require RadioLib to disable specific drivers (such as ESP8266). * @@ -699,6 +700,10 @@ #define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void) #define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void) + // provide an easy access to the on-board module + #include "board-config.h" + #define RADIOLIB_BUILTIN_MODULE RADIO_NSS, RADIO_DIO_1, RADIO_RESET, RADIO_BUSY + // CubeCell doesn't seem to define nullptr, let's do something like that now #define nullptr NULL