diff --git a/src/modules/SX1262.cpp b/src/modules/SX1262.cpp index 0bcce47d..59ee7225 100644 --- a/src/modules/SX1262.cpp +++ b/src/modules/SX1262.cpp @@ -22,6 +22,11 @@ int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint16_t syn return(state); } + state = fixPaClamping(); + if (state != ERR_NONE) { + return state; + } + return(state); } @@ -110,3 +115,13 @@ int16_t SX1262::setOutputPower(int8_t power) { // restore OCP configuration return(writeRegister(SX126X_REG_OCP_CONFIGURATION, &ocp, 1)); } + +int16_t SX1262::fixPaClamping() { + uint8_t clampConfig; + uint16_t state = readRegister(SX126X_REG_TX_CLAMP_CONFIG, &clampConfig, 1); + if (state != ERR_NONE) { + return state; + } + clampConfig |= 0x1E; + return writeRegister(SX126X_REG_TX_CLAMP_CONFIG, &clampConfig, 1); +} diff --git a/src/modules/SX1262.h b/src/modules/SX1262.h index 88a49576..5e23d73f 100644 --- a/src/modules/SX1262.h +++ b/src/modules/SX1262.h @@ -8,6 +8,7 @@ //SX126X_CMD_SET_PA_CONFIG #define SX126X_PA_CONFIG_SX1261 0x01 #define SX126X_PA_CONFIG_SX1262 0x00 +#define SX126X_REG_TX_CLAMP_CONFIG 0x08D8 //Datasheet 15.2 /*! \class SX1262 @@ -94,8 +95,10 @@ class SX1262: public SX126x { int16_t setOutputPower(int8_t power); private: - - + /*! + \brief Fixes overly eager PA clamping, as described in section 15.2 of the datasheet + */ + int16_t fixPaClamping(); }; #endif