From 977b2c28c8989167719e9f0df8ee69b67b3feddb Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 13 Feb 2025 18:57:44 +0100 Subject: [PATCH] [nRF24] Add public LNA control method (#1392) --- src/modules/nRF24/nRF24.cpp | 4 ++++ src/modules/nRF24/nRF24.h | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 105ac298..a6c2f841 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -561,6 +561,10 @@ int16_t nRF24::setEncoding(uint8_t encoding) { return(RADIOLIB_ERR_NONE); } +int16_t nRF24::setLNA(bool enable) { + return(this->mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, enable ? RADIOLIB_NRF24_RF_LNA_ON : RADIOLIB_NRF24_RF_LNA_OFF, 0, 0)); +} + void nRF24::clearIRQ() { // clear status bits this->mod->SPIsetRegValue(RADIOLIB_NRF24_REG_STATUS, RADIOLIB_NRF24_RX_DR | RADIOLIB_NRF24_TX_DS | RADIOLIB_NRF24_MAX_RT, 6, 4); diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index e7db4ec5..48d21fe7 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -123,6 +123,8 @@ #define RADIOLIB_NRF24_RF_PWR_12_DBM 0b00000010 // 2 1 -12 dBm #define RADIOLIB_NRF24_RF_PWR_6_DBM 0b00000100 // 2 1 -6 dBm #define RADIOLIB_NRF24_RF_PWR_0_DBM 0b00000110 // 2 1 0 dBm (default) +#define RADIOLIB_NRF24_RF_LNA_OFF 0b00000000 // 0 0 LNA gain: Off +#define RADIOLIB_NRF24_RF_LNA_ON 0b00000001 // 0 0 On // RADIOLIB_NRF24_REG_STATUS #define RADIOLIB_NRF24_RX_DR 0b01000000 // 6 6 Rx data ready @@ -464,6 +466,14 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ int16_t setEncoding(uint8_t encoding) override; + + /*! + \brief Enable or disable the low-noise amplifier. + Improves receive performance at the cost of increased power consumption. + \param enable True to enable. + \returns \ref status_codes + */ + int16_t setLNA(bool enable); #if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: