diff --git a/src/modules/RFM9x/RFM95.cpp b/src/modules/RFM9x/RFM95.cpp index b6a84e7e..ff614852 100644 --- a/src/modules/RFM9x/RFM95.cpp +++ b/src/modules/RFM9x/RFM95.cpp @@ -19,10 +19,6 @@ int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278")); RADIOLIB_DEBUG_PRINTLN(F("M\tRFM95")); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/RFM9x/RFM96.cpp b/src/modules/RFM9x/RFM96.cpp index d7854c9f..2d6978b9 100644 --- a/src/modules/RFM9x/RFM96.cpp +++ b/src/modules/RFM9x/RFM96.cpp @@ -18,11 +18,7 @@ int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW } RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278")); RADIOLIB_DEBUG_PRINTLN(F("M\tRFM96")); - - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - + // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index e4c0bb60..f6b23efc 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -10,10 +10,6 @@ int16_t SX1272::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // mitigation of receiver spurious response // see SX1272/73 Errata, section 2.2 for details state = _mod->SPIsetRegValue(0x31, 0b10000000, 7, 7); @@ -46,10 +42,6 @@ int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t int16_t state = SX127x::beginFSK(SX1272_CHIP_VERSION, br, rxBw, freqDev, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1273.cpp b/src/modules/SX127x/SX1273.cpp index 97178f81..49e12e3c 100644 --- a/src/modules/SX127x/SX1273.cpp +++ b/src/modules/SX127x/SX1273.cpp @@ -10,10 +10,6 @@ int16_t SX1273::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // mitigation of receiver spurious response // see SX1272/73 Errata, section 2.2 for details state = _mod->SPIsetRegValue(0x31, 0b10000000, 7, 7); diff --git a/src/modules/SX127x/SX1276.cpp b/src/modules/SX127x/SX1276.cpp index 848f0949..fa99cef2 100644 --- a/src/modules/SX127x/SX1276.cpp +++ b/src/modules/SX127x/SX1276.cpp @@ -10,10 +10,6 @@ int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -41,10 +37,6 @@ int16_t SX1276::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1277.cpp b/src/modules/SX127x/SX1277.cpp index 005f1ca0..284b7c87 100644 --- a/src/modules/SX127x/SX1277.cpp +++ b/src/modules/SX127x/SX1277.cpp @@ -10,10 +10,6 @@ int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -41,10 +37,6 @@ int16_t SX1277::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 906c4e07..efa065c6 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -10,10 +10,6 @@ int16_t SX1278::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -41,10 +37,6 @@ int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1279.cpp b/src/modules/SX127x/SX1279.cpp index 346643d0..ad580404 100644 --- a/src/modules/SX127x/SX1279.cpp +++ b/src/modules/SX127x/SX1279.cpp @@ -10,10 +10,6 @@ int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -41,10 +37,6 @@ int16_t SX1279::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index a08b0374..e842cdd0 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -23,6 +23,10 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLe int16_t state = standby(); RADIOLIB_ASSERT(state); + // configure settings not accessible by API + state = config(); + RADIOLIB_ASSERT(state); + // check active modem if(getActiveModem() != SX127X_LORA) { // set LoRa mode @@ -61,8 +65,15 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB } RADIOLIB_DEBUG_PRINTLN(F("M\tSX127x")); + // set mode to standby + int16_t state = standby(); + RADIOLIB_ASSERT(state); + + // configure settings not accessible by API + state = configFSK(); + RADIOLIB_ASSERT(state); + // check currently active modem - int16_t state; if(getActiveModem() != SX127X_FSK_OOK) { // set FSK mode state = setActiveModem(SX127X_FSK_OOK); @@ -1059,7 +1070,7 @@ int16_t SX127x::configFSK() { _mod->SPIwriteRegister(SX127X_REG_IRQ_FLAGS_2, SX127X_FLAG_FIFO_OVERRUN); // set packet configuration - state = _mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_1, SX127X_PACKET_VARIABLE | SX127X_DC_FREE_WHITENING | SX127X_CRC_ON | SX127X_CRC_AUTOCLEAR_ON | SX127X_ADDRESS_FILTERING_OFF | SX127X_CRC_WHITENING_TYPE_CCITT, 7, 0); + state = _mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_1, SX127X_PACKET_VARIABLE | SX127X_DC_FREE_NONE | SX127X_CRC_ON | SX127X_CRC_AUTOCLEAR_ON | SX127X_ADDRESS_FILTERING_OFF | SX127X_CRC_WHITENING_TYPE_CCITT, 7, 0); state |= _mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_2, SX127X_DATA_MODE_PACKET | SX127X_IO_HOME_OFF, 6, 5); RADIOLIB_ASSERT(state); @@ -1078,10 +1089,8 @@ int16_t SX127x::configFSK() { state |= _mod->SPIsetRegValue(SX127X_REG_RX_TIMEOUT_3, SX127X_TIMEOUT_SIGNAL_SYNC_OFF); RADIOLIB_ASSERT(state); - // enable preamble detector and set preamble length + // enable preamble detector state = _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_DETECT, SX127X_PREAMBLE_DETECTOR_ON | SX127X_PREAMBLE_DETECTOR_2_BYTE | SX127X_PREAMBLE_DETECTOR_TOL); - state |= _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_MSB_FSK, SX127X_PREAMBLE_SIZE_MSB); - state |= _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_LSB_FSK, SX127X_PREAMBLE_SIZE_LSB); return(state); }