From c3e99c8698269f3eba1a3b4682a40d65c35e1fbb Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 26 May 2024 14:11:05 +0200 Subject: [PATCH] [LR11x0] Make regulator mode and Rx gain config public (#1108) --- src/modules/LR11x0/LR11x0.cpp | 27 ++++++++++++++++++++++----- src/modules/LR11x0/LR11x0.h | 20 +++++++++++++++++++- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/modules/LR11x0/LR11x0.cpp b/src/modules/LR11x0/LR11x0.cpp index 7c61568fc..c9d44f695 100644 --- a/src/modules/LR11x0/LR11x0.cpp +++ b/src/modules/LR11x0/LR11x0.cpp @@ -44,6 +44,9 @@ int16_t LR11x0::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t state = invertIQ(false); RADIOLIB_ASSERT(state); + state = setRegulatorLDO(); + RADIOLIB_ASSERT(state); + return(RADIOLIB_ERR_NONE); } @@ -85,6 +88,9 @@ int16_t LR11x0::beginGFSK(float br, float freqDev, float rxBw, int8_t power, uin state = setCRC(2); RADIOLIB_ASSERT(state); + state = setRegulatorLDO(); + RADIOLIB_ASSERT(state); + return(RADIOLIB_ERR_NONE); } @@ -103,6 +109,9 @@ int16_t LR11x0::beginLRFHSS(uint8_t bw, uint8_t cr, int8_t power, float tcxoVolt state = setSyncWord(0x12AD101B); RADIOLIB_ASSERT(state); + state = setRegulatorLDO(); + RADIOLIB_ASSERT(state); + // set fixed configuration return(setModulationParamsLrFhss(RADIOLIB_LR11X0_LR_FHSS_BIT_RATE_RAW, RADIOLIB_LR11X0_LR_FHSS_SHAPING_GAUSSIAN_BT_1_0)); } @@ -1363,6 +1372,19 @@ float LR11x0::getDataRate() const { return(this->dataRateMeasured); } +int16_t LR11x0::setRegulatorLDO() { + return(this->setRegMode(RADIOLIB_LR11X0_REG_MODE_LDO)); +} + +int16_t LR11x0::setRegulatorDCDC() { + return(this->setRegMode(RADIOLIB_LR11X0_REG_MODE_DC_DC)); +} + +int16_t LR11x0::setRxBoostedGainMode(bool en) { + uint8_t buff[1] = { (uint8_t)en }; + return(this->SPIcommand(RADIOLIB_LR11X0_CMD_SET_RX_BOOSTED, true, buff, sizeof(buff))); +} + int16_t LR11x0::setLrFhssConfig(uint8_t bw, uint8_t cr, uint8_t hdrCount, uint16_t hopSeed) { // check active modem uint8_t type = RADIOLIB_LR11X0_PACKET_TYPE_NONE; @@ -2476,11 +2498,6 @@ int16_t LR11x0::setGfskWhitParams(uint16_t seed) { return(this->SPIcommand(RADIOLIB_LR11X0_CMD_SET_GFSK_WHIT_PARAMS, true, buff, sizeof(buff))); } -int16_t LR11x0::setRxBoosted(bool en) { - uint8_t buff[1] = { (uint8_t)en }; - return(this->SPIcommand(RADIOLIB_LR11X0_CMD_SET_RX_BOOSTED, true, buff, sizeof(buff))); -} - int16_t LR11x0::setRangingParameter(uint8_t symbolNum) { // the first byte is reserved uint8_t buff[2] = { 0x00, symbolNum }; diff --git a/src/modules/LR11x0/LR11x0.h b/src/modules/LR11x0/LR11x0.h index 1f87df811..1c48b536f 100644 --- a/src/modules/LR11x0/LR11x0.h +++ b/src/modules/LR11x0/LR11x0.h @@ -1247,6 +1247,25 @@ class LR11x0: public PhysicalLayer { */ float getDataRate() const; + /*! + \brief Set regulator mode to LDO. + \returns \ref status_codes + */ + int16_t setRegulatorLDO(); + + /*! + \brief Set regulator mode to DC-DC. + \returns \ref status_codes + */ + int16_t setRegulatorDCDC(); + + /*! + \brief Enables or disables Rx Boosted Gain mode (additional Rx gain for increased power consumption). + \param en True for Rx Boosted Gain, false for Rx Power Saving Gain + \returns \ref status_codes + */ + int16_t setRxBoostedGainMode(bool en); + /*! \brief Sets LR-FHSS configuration. \param bw LR-FHSS bandwidth, one of RADIOLIB_LR11X0_LR_FHSS_BW_* values. @@ -1416,7 +1435,6 @@ class LR11x0: public PhysicalLayer { int16_t setRangingTxRxDelay(uint32_t delay); int16_t setGfskCrcParams(uint32_t init, uint32_t poly); int16_t setGfskWhitParams(uint16_t seed); - int16_t setRxBoosted(bool en); int16_t setRangingParameter(uint8_t symbolNum); int16_t setRssiCalibration(const int8_t* tune, int16_t gainOffset); int16_t setLoRaSyncWord(uint8_t sync);