From bd5d824d7337e3d59d4aeae9061a4a88be7d6d15 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 14 Nov 2021 11:41:27 +0100 Subject: [PATCH] [SX1231] Update to 5.0.0 --- .../SX1231/SX1231_Receive/SX1231_Receive.ino | 8 +++---- .../SX1231_Transmit/SX1231_Transmit.ino | 6 ++--- src/modules/SX1231/SX1231.cpp | 24 +++++++++---------- src/modules/SX1231/SX1231.h | 10 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/SX1231/SX1231_Receive/SX1231_Receive.ino b/examples/SX1231/SX1231_Receive/SX1231_Receive.ino index 18d0354c..cd3efea4 100644 --- a/examples/SX1231/SX1231_Receive/SX1231_Receive.ino +++ b/examples/SX1231/SX1231_Receive/SX1231_Receive.ino @@ -33,7 +33,7 @@ void setup() { // initialize SX1231 with default settings Serial.print(F("[SX1231] Initializing ... ")); int state = radio.begin(); - if (state == ERR_NONE) { + if (state == RADIOLIB_ERR_NONE) { Serial.println(F("success!")); } else { Serial.print(F("failed, code ")); @@ -55,7 +55,7 @@ void loop() { int state = radio.receive(byteArr, 8); */ - if (state == ERR_NONE) { + if (state == RADIOLIB_ERR_NONE) { // packet was successfully received Serial.println(F("success!")); @@ -63,11 +63,11 @@ void loop() { Serial.print(F("[SX1231] Data:\t\t")); Serial.println(str); - } else if (state == ERR_RX_TIMEOUT) { + } else if (state == RADIOLIB_ERR_RX_TIMEOUT) { // timeout occurred while waiting for a packet Serial.println(F("timeout!")); - } else if (state == ERR_CRC_MISMATCH) { + } else if (state == RADIOLIB_ERR_CRC_MISMATCH) { // packet was received, but is malformed Serial.println(F("CRC error!")); diff --git a/examples/SX1231/SX1231_Transmit/SX1231_Transmit.ino b/examples/SX1231/SX1231_Transmit/SX1231_Transmit.ino index 0f8cd14b..44db4556 100644 --- a/examples/SX1231/SX1231_Transmit/SX1231_Transmit.ino +++ b/examples/SX1231/SX1231_Transmit/SX1231_Transmit.ino @@ -33,7 +33,7 @@ void setup() { // initialize SX1231 with default settings Serial.print(F("[SX1231] Initializing ... ")); int state = radio.begin(); - if (state == ERR_NONE) { + if (state == RADIOLIB_ERR_NONE) { Serial.println(F("success!")); } else { Serial.print(F("failed, code ")); @@ -54,11 +54,11 @@ void loop() { int state = radio.transmit(byteArr, 8); */ - if (state == ERR_NONE) { + if (state == RADIOLIB_ERR_NONE) { // the packet was successfully transmitted Serial.println(F("success!")); - } else if (state == ERR_PACKET_TOO_LONG) { + } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) { // the supplied packet was longer than 256 bytes Serial.println(F("too long!")); diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index 3148556f..1681d6bf 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -7,9 +7,9 @@ SX1231::SX1231(Module* mod) : RF69(mod) { int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t power, uint8_t preambleLen) { // set module properties - _mod->init(RADIOLIB_USE_SPI); - Module::pinMode(_mod->getIrq(), INPUT); - Module::pinMode(_mod->getRst(), OUTPUT); + _mod->init(); + _mod->pinMode(_mod->getIrq(), INPUT); + _mod->pinMode(_mod->getRst(), OUTPUT); // try to find the SX1231 chip uint8_t i = 0; @@ -20,7 +20,7 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po flagFound = true; _chipRevision = version; } else { - #ifdef RADIOLIB_DEBUG + #if defined(RADIOLIB_DEBUG) RADIOLIB_DEBUG_PRINT(F("SX1231 not found! (")); RADIOLIB_DEBUG_PRINT(i + 1); RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RF69_REG_VERSION == ")); @@ -31,15 +31,15 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po RADIOLIB_DEBUG_PRINT(F(", expected 0x0021 / 0x0022 / 0x0023")); RADIOLIB_DEBUG_PRINTLN(); #endif - Module::delay(10); + _mod->delay(10); i++; } } if(!flagFound) { RADIOLIB_DEBUG_PRINTLN(F("No SX1231 found!")); - _mod->term(RADIOLIB_USE_SPI); - return(ERR_CHIP_NOT_FOUND); + _mod->term(); + return(RADIOLIB_ERR_CHIP_NOT_FOUND); } RADIOLIB_DEBUG_PRINTLN(F("M\tSX1231")); @@ -80,22 +80,22 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po // set default packet length mode state = variablePacketLengthMode(); - if (state != ERR_NONE) { + if (state != RADIOLIB_ERR_NONE) { return(state); } // SX1231 V2a only - if(_chipRevision == SX1231_CHIP_REVISION_2_A) { + if(_chipRevision == RADIOLIB_SX1231_CHIP_REVISION_2_A) { // modify default OOK threshold value - state = _mod->SPIsetRegValue(SX1231_REG_TEST_OOK, SX1231_OOK_DELTA_THRESHOLD); + state = _mod->SPIsetRegValue(RADIOLIB_SX1231_REG_TEST_OOK, RADIOLIB_SX1231_OOK_DELTA_THRESHOLD); RADIOLIB_ASSERT(state); // enable OCP with 95 mA limit - state = _mod->SPIsetRegValue(RF69_REG_OCP, RF69_OCP_ON | RF69_OCP_TRIM, 4, 0); + state = _mod->SPIsetRegValue(RADIOLIB_RF69_REG_OCP, RADIOLIB_RF69_OCP_ON | RADIOLIB_RF69_OCP_TRIM, 4, 0); RADIOLIB_ASSERT(state); } - return(ERR_NONE); + return(RADIOLIB_ERR_NONE); } #endif diff --git a/src/modules/SX1231/SX1231.h b/src/modules/SX1231/SX1231.h index 5ad6ac94..ada7dbb9 100644 --- a/src/modules/SX1231/SX1231.h +++ b/src/modules/SX1231/SX1231.h @@ -8,15 +8,15 @@ #include "../../Module.h" #include "../RF69/RF69.h" -#define SX1231_CHIP_REVISION_2_A 0x21 -#define SX1231_CHIP_REVISION_2_B 0x22 -#define SX1231_CHIP_REVISION_2_C 0x23 +#define RADIOLIB_SX1231_CHIP_REVISION_2_A 0x21 +#define RADIOLIB_SX1231_CHIP_REVISION_2_B 0x22 +#define RADIOLIB_SX1231_CHIP_REVISION_2_C 0x23 //SX1231 specific register map -#define SX1231_REG_TEST_OOK 0x6E +#define RADIOLIB_SX1231_REG_TEST_OOK 0x6E //SX1231_REG_TEST_OOK -#define SX1231_OOK_DELTA_THRESHOLD 0x0C +#define RADIOLIB_SX1231_OOK_DELTA_THRESHOLD 0x0C /*! \class SX1231