From e1141ca64c2f19110eac84f123d89861e98c4650 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:48:14 +0200 Subject: [PATCH] [SX127x] Synced parameters of all LoRa modules --- examples/SX127x/SX127x_Settings/SX127x_Settings.ino | 3 +-- src/modules/SX127x/SX1272.cpp | 4 ++-- src/modules/SX127x/SX1272.h | 4 +--- src/modules/SX127x/SX1273.cpp | 5 +++-- src/modules/SX127x/SX1273.h | 5 +---- src/modules/SX127x/SX1276.cpp | 5 +++-- src/modules/SX127x/SX1276.h | 5 +---- src/modules/SX127x/SX1277.cpp | 5 +++-- src/modules/SX127x/SX1277.h | 5 +---- src/modules/SX127x/SX1278.cpp | 4 ++-- src/modules/SX127x/SX1278.h | 5 +---- src/modules/SX127x/SX1279.cpp | 5 +++-- src/modules/SX127x/SX1279.h | 5 +---- src/modules/SX127x/SX127x.cpp | 4 ++-- src/modules/SX127x/SX127x.h | 4 +--- 15 files changed, 26 insertions(+), 42 deletions(-) diff --git a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino index 08d1c967..84f31fac 100644 --- a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino +++ b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino @@ -70,10 +70,9 @@ void setup() { // coding rate: 5 // sync word: 0x14 // output power: 2 dBm - // current limit: 50 mA // preamble length: 20 symbols // amplifier gain: 1 (maximum gain) - state = radio2.begin(915.0, 500.0, 6, 5, 0x14, 2); + state = radio2.begin(915.0, 500.0, 6, 5, 0x14, 2, 20, 1); if (state == ERR_NONE) { Serial.println(F("success!")); } else { diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 503923e9..e6219fc2 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -5,9 +5,9 @@ SX1272::SX1272(Module* mod) : SX127x(mod) { } -int16_t SX1272::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1272::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index f65539f2..26a5b84a 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -119,8 +119,6 @@ class SX1272: public SX127x { \param syncWord %LoRa sync word. Can be used to distinguish different networks. Note that value 0x34 is reserved for LoRaWAN networks. - \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. Set to 0 to disable OCP (not recommended). @@ -132,7 +130,7 @@ class SX1272: public SX127x { \returns \ref status_codes */ - int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); /*! \brief FSK modem initialization method. Must be called at least once from Arduino sketch to initialize the module. diff --git a/src/modules/SX127x/SX1273.cpp b/src/modules/SX127x/SX1273.cpp index b45ca0e5..97178f81 100644 --- a/src/modules/SX127x/SX1273.cpp +++ b/src/modules/SX127x/SX1273.cpp @@ -5,9 +5,9 @@ SX1273::SX1273(Module* mod) : SX1272(mod) { } -int16_t SX1273::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1273::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -36,6 +36,7 @@ int16_t SX1273::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1273.h b/src/modules/SX127x/SX1273.h index e8b3902b..83b43dd4 100644 --- a/src/modules/SX127x/SX1273.h +++ b/src/modules/SX127x/SX1273.h @@ -41,9 +41,6 @@ class SX1273: public SX1272 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -52,7 +49,7 @@ class SX1273: public SX1272 { \returns \ref status_codes */ - int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/SX127x/SX1276.cpp b/src/modules/SX127x/SX1276.cpp index 66510443..b331fe95 100644 --- a/src/modules/SX127x/SX1276.cpp +++ b/src/modules/SX127x/SX1276.cpp @@ -5,9 +5,9 @@ SX1276::SX1276(Module* mod) : SX1278(mod) { } -int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -31,6 +31,7 @@ int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1276.h b/src/modules/SX127x/SX1276.h index cc4ce493..ec6e33d6 100644 --- a/src/modules/SX127x/SX1276.h +++ b/src/modules/SX127x/SX1276.h @@ -41,9 +41,6 @@ class SX1276: public SX1278 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -52,7 +49,7 @@ class SX1276: public SX1278 { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/SX127x/SX1277.cpp b/src/modules/SX127x/SX1277.cpp index fe187055..371c125e 100644 --- a/src/modules/SX127x/SX1277.cpp +++ b/src/modules/SX127x/SX1277.cpp @@ -5,9 +5,9 @@ SX1277::SX1277(Module* mod) : SX1278(mod) { } -int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -31,6 +31,7 @@ int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1277.h b/src/modules/SX127x/SX1277.h index 804ee6f9..6598f066 100644 --- a/src/modules/SX127x/SX1277.h +++ b/src/modules/SX127x/SX1277.h @@ -41,9 +41,6 @@ class SX1277: public SX1278 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -52,7 +49,7 @@ class SX1277: public SX1278 { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index b4c37576..2e0566a0 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -5,9 +5,9 @@ SX1278::SX1278(Module* mod) : SX127x(mod) { } -int16_t SX1278::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1278::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index fe136361..b25d7be8 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -130,9 +130,6 @@ class SX1278: public SX127x { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -141,7 +138,7 @@ class SX1278: public SX127x { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); /*! \brief FSK modem initialization method. Must be called at least once from Arduino sketch to initialize the module. diff --git a/src/modules/SX127x/SX1279.cpp b/src/modules/SX127x/SX1279.cpp index 9d5562e5..21d1f598 100644 --- a/src/modules/SX127x/SX1279.cpp +++ b/src/modules/SX127x/SX1279.cpp @@ -5,9 +5,9 @@ SX1279::SX1279(Module* mod) : SX1278(mod) { } -int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -31,6 +31,7 @@ int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1279.h b/src/modules/SX127x/SX1279.h index c466b64a..27220119 100644 --- a/src/modules/SX127x/SX1279.h +++ b/src/modules/SX127x/SX1279.h @@ -41,9 +41,6 @@ class SX1279: public SX1278 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -52,7 +49,7 @@ class SX1279: public SX1278 { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 557035d8..3e464260 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -5,7 +5,7 @@ SX127x::SX127x(Module* mod) : PhysicalLayer(SX127X_FREQUENCY_STEP_SIZE, SX127X_M _mod = mod; } -int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimit, uint16_t preambleLength) { +int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLength) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -36,7 +36,7 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimi RADIOLIB_ASSERT(state); // set over current protection - state = SX127x::setCurrentLimit(currentLimit); + state = SX127x::setCurrentLimit(60); RADIOLIB_ASSERT(state); // set preamble length diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 04a28bc5..61953144 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -559,13 +559,11 @@ class SX127x: public PhysicalLayer { \param syncWord %LoRa sync word. - \param currentLimit Trim value for OCP (over current protection) in mA. - \param preambleLength Length of %LoRa transmission preamble in symbols. \returns \ref status_codes */ - int16_t begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimit, uint16_t preambleLength); + int16_t begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLength); /*! \brief Reset method. Will reset the chip to the default state using RST pin. Declared pure virtual since SX1272 and SX1278 implementations differ.