From 06ef449b68fb698914d4becaff2fa18b099bb489 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Mon, 17 Jan 2022 11:47:49 -0700 Subject: [PATCH] Move helper functions from SX1276/7/8/9 to global SX127x. --- src/modules/SX127x/SX1276.cpp | 22 ---------------------- src/modules/SX127x/SX1276.h | 28 ---------------------------- src/modules/SX127x/SX1277.cpp | 20 -------------------- src/modules/SX127x/SX1277.h | 28 ---------------------------- src/modules/SX127x/SX1278.cpp | 21 --------------------- src/modules/SX127x/SX1278.h | 28 ---------------------------- src/modules/SX127x/SX1279.cpp | 21 --------------------- src/modules/SX127x/SX1279.h | 28 ---------------------------- src/modules/SX127x/SX127x.cpp | 21 +++++++++++++++++++++ src/modules/SX127x/SX127x.h | 28 ++++++++++++++++++++++++++++ 10 files changed, 49 insertions(+), 196 deletions(-) diff --git a/src/modules/SX127x/SX1276.cpp b/src/modules/SX127x/SX1276.cpp index fa1b46b8..c4c32f9c 100644 --- a/src/modules/SX127x/SX1276.cpp +++ b/src/modules/SX127x/SX1276.cpp @@ -70,26 +70,4 @@ int16_t SX1276::setFrequency(float freq) { return(state); } -int16_t SX1276::setFHSSHoppingPeriod(uint8_t freqHoppingPeriod) { - return(_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD, freqHoppingPeriod)); -} - -uint8_t SX1276::getFHSSHoppingPeriod(void) { - return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD)); -} - -uint8_t SX1276::getFHSSChannel(void) { - return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_CHANNEL, 5, 0)); -} - -void SX1276::clearFHSSInt(void) { - int16_t modem = getActiveModem(); - if(modem == RADIOLIB_SX127X_LORA) { - _mod->SPIwriteRegister(RADIOLIB_SX127X_REG_IRQ_FLAGS, getIRQFlags() | RADIOLIB_SX127X_CLEAR_IRQ_FLAG_FHSS_CHANGE_CHANNEL); - } else if(modem == RADIOLIB_SX127X_FSK_OOK) { - return; //These are not the interrupts you are looking for - } -} - - #endif diff --git a/src/modules/SX127x/SX1276.h b/src/modules/SX127x/SX1276.h index 15006ce3..cdc4cac5 100644 --- a/src/modules/SX127x/SX1276.h +++ b/src/modules/SX127x/SX1276.h @@ -84,34 +84,6 @@ class SX1276: public SX1278 { */ int16_t setFrequency(float freq); - /*! - \brief Sets the hopping period and enables FHSS - - \param freqHoppingPeriod Integer multiple of symbol periods between hops - - \returns \ref status_codes - */ - int16_t setFHSSHoppingPeriod(uint8_t freqHoppingPeriod); - - /*! - \brief Gets FHSS hopping period - - \returns 8 bit period - */ - uint8_t getFHSSHoppingPeriod(void); - - /*! - \brief Gets the FHSS channel in use - - \returns 6 bit channel number - */ - uint8_t getFHSSChannel(void); - - /*! - \brief Clear the FHSS interrupt - */ - void clearFHSSInt(void); - #if !defined(RADIOLIB_GODMODE) private: #endif diff --git a/src/modules/SX127x/SX1277.cpp b/src/modules/SX127x/SX1277.cpp index 2bc2790a..59250e45 100644 --- a/src/modules/SX127x/SX1277.cpp +++ b/src/modules/SX127x/SX1277.cpp @@ -100,24 +100,4 @@ int16_t SX1277::setSpreadingFactor(uint8_t sf) { return(state); } -int16_t SX1277::setFHSSHoppingPeriod(uint8_t freqHoppingPeriod) { - return(_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD, freqHoppingPeriod)); -} - -uint8_t SX1277::getFHSSHoppingPeriod(void) { - return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD)); -} - -uint8_t SX1277::getFHSSChannel(void) { - return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_CHANNEL, 5, 0)); -} - -void SX1277::clearFHSSInt(void) { - int16_t modem = getActiveModem(); - if(modem == RADIOLIB_SX127X_LORA) { - _mod->SPIwriteRegister(RADIOLIB_SX127X_REG_IRQ_FLAGS, getIRQFlags() | RADIOLIB_SX127X_CLEAR_IRQ_FLAG_FHSS_CHANGE_CHANNEL); - } else if(modem == RADIOLIB_SX127X_FSK_OOK) { - return; //These are not the interrupts you are looking for - } -} #endif diff --git a/src/modules/SX127x/SX1277.h b/src/modules/SX127x/SX1277.h index fed18de5..b9f7a5cf 100644 --- a/src/modules/SX127x/SX1277.h +++ b/src/modules/SX127x/SX1277.h @@ -93,34 +93,6 @@ class SX1277: public SX1278 { */ int16_t setSpreadingFactor(uint8_t sf); - /*! - \brief Sets the hopping period and enables FHSS - - \param freqHoppingPeriod Integer multiple of symbol periods between hops - - \returns \ref status_codes - */ - int16_t setFHSSHoppingPeriod(uint8_t freqHoppingPeriod); - - /*! - \brief Gets FHSS hopping period - - \returns 8 bit period - */ - uint8_t getFHSSHoppingPeriod(void); - - /*! - \brief Gets the FHSS channel in use - - \returns 6 bit channel number - */ - uint8_t getFHSSChannel(void); - - /*! - \brief Clear the FHSS interrupt - */ - void clearFHSSInt(void); - #if !defined(RADIOLIB_GODMODE) private: #endif diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 71ba02e1..317c38ee 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -623,25 +623,4 @@ void SX1278::errataFix(bool rx) { _mod->SPIsetRegValue(0x30, fixedRegs[2]); } -int16_t SX1278::setFHSSHoppingPeriod(uint8_t freqHoppingPeriod) { - return(_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD, freqHoppingPeriod)); -} - -uint8_t SX1278::getFHSSHoppingPeriod(void) { - return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD)); -} - -uint8_t SX1278::getFHSSChannel(void) { - return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_CHANNEL, 5, 0)); -} - -void SX1278::clearFHSSInt(void) { - int16_t modem = getActiveModem(); - if(modem == RADIOLIB_SX127X_LORA) { - _mod->SPIwriteRegister(RADIOLIB_SX127X_REG_IRQ_FLAGS, getIRQFlags() | RADIOLIB_SX127X_CLEAR_IRQ_FLAG_FHSS_CHANGE_CHANNEL); - } else if(modem == RADIOLIB_SX127X_FSK_OOK) { - return; //These are not the interrupts you are looking for - } -} - #endif diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index 533a0da9..150b97c3 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -302,34 +302,6 @@ class SX1278: public SX127x { */ int16_t explicitHeader(); - /*! - \brief Sets the hopping period and enables FHSS - - \param freqHoppingPeriod Integer multiple of symbol periods between hops - - \returns \ref status_codes - */ - int16_t setFHSSHoppingPeriod(uint8_t freqHoppingPeriod); - - /*! - \brief Gets FHSS hopping period - - \returns 8 bit period - */ - uint8_t getFHSSHoppingPeriod(void); - - /*! - \brief Gets the FHSS channel in use - - \returns 6 bit channel number - */ - uint8_t getFHSSChannel(void); - - /*! - \brief Clear the FHSS interrupt - */ - void clearFHSSInt(void); - #if !defined(RADIOLIB_GODMODE) protected: #endif diff --git a/src/modules/SX127x/SX1279.cpp b/src/modules/SX127x/SX1279.cpp index 286d0f47..1eac9dc9 100644 --- a/src/modules/SX127x/SX1279.cpp +++ b/src/modules/SX127x/SX1279.cpp @@ -70,25 +70,4 @@ int16_t SX1279::setFrequency(float freq) { return(state); } -int16_t SX1279::setFHSSHoppingPeriod(uint8_t freqHoppingPeriod) { - return(_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD, freqHoppingPeriod)); -} - -uint8_t SX1279::getFHSSHoppingPeriod(void) { - return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD)); -} - -uint8_t SX1279::getFHSSChannel(void) { - return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_CHANNEL, 5, 0)); -} - -void SX1279::clearFHSSInt(void) { - int16_t modem = getActiveModem(); - if(modem == RADIOLIB_SX127X_LORA) { - _mod->SPIwriteRegister(RADIOLIB_SX127X_REG_IRQ_FLAGS, getIRQFlags() | RADIOLIB_SX127X_CLEAR_IRQ_FLAG_FHSS_CHANGE_CHANNEL); - } else if(modem == RADIOLIB_SX127X_FSK_OOK) { - return; //These are not the interrupts you are looking for - } -} - #endif diff --git a/src/modules/SX127x/SX1279.h b/src/modules/SX127x/SX1279.h index 5328213b..c9ff8ab0 100644 --- a/src/modules/SX127x/SX1279.h +++ b/src/modules/SX127x/SX1279.h @@ -84,34 +84,6 @@ class SX1279: public SX1278 { */ int16_t setFrequency(float freq); - /*! - \brief Sets the hopping period and enables FHSS - - \param freqHoppingPeriod Integer multiple of symbol periods between hops - - \returns \ref status_codes - */ - int16_t setFHSSHoppingPeriod(uint8_t freqHoppingPeriod); - - /*! - \brief Gets FHSS hopping period - - \returns 8 bit period - */ - uint8_t getFHSSHoppingPeriod(void); - - /*! - \brief Gets the FHSS channel in use - - \returns 6 bit channel number - */ - uint8_t getFHSSChannel(void); - - /*! - \brief Clear the FHSS interrupt - */ - void clearFHSSInt(void); - #if !defined(RADIOLIB_GODMODE) private: #endif diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 15736a0a..1db50c20 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -1367,4 +1367,25 @@ void SX127x::readBit(RADIOLIB_PIN_TYPE pin) { updateDirectBuffer((uint8_t)digitalRead(pin)); } +int16_t SX127x::setFHSSHoppingPeriod(uint8_t freqHoppingPeriod) { + return(_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD, freqHoppingPeriod)); +} + +uint8_t SX127x::getFHSSHoppingPeriod(void) { + return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD)); +} + +uint8_t SX127x::getFHSSChannel(void) { + return(_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_HOP_CHANNEL, 5, 0)); +} + +void SX127x::clearFHSSInt(void) { + int16_t modem = getActiveModem(); + if(modem == RADIOLIB_SX127X_LORA) { + _mod->SPIwriteRegister(RADIOLIB_SX127X_REG_IRQ_FLAGS, getIRQFlags() | RADIOLIB_SX127X_CLEAR_IRQ_FLAG_FHSS_CHANGE_CHANNEL); + } else if(modem == RADIOLIB_SX127X_FSK_OOK) { + return; //These are not the interrupts you are looking for + } +} + #endif diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 66ab01c8..b0671bac 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -1073,6 +1073,34 @@ class SX127x: public PhysicalLayer { */ void readBit(RADIOLIB_PIN_TYPE pin); + /*! + \brief Sets the hopping period and enables FHSS + + \param freqHoppingPeriod Integer multiple of symbol periods between hops + + \returns \ref status_codes + */ + int16_t setFHSSHoppingPeriod(uint8_t freqHoppingPeriod); + + /*! + \brief Gets FHSS hopping period + + \returns 8 bit period + */ + uint8_t getFHSSHoppingPeriod(void); + + /*! + \brief Gets the FHSS channel in use + + \returns 6 bit channel number + */ + uint8_t getFHSSChannel(void); + + /*! + \brief Clear the FHSS interrupt + */ + void clearFHSSInt(void); + #if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) protected: #endif