Line data Source code
1 : #include "SX1261.h" 2 : #if !RADIOLIB_EXCLUDE_SX126X 3 : 4 1 : SX1261::SX1261(Module* mod): SX1262(mod) { 5 1 : chipType = RADIOLIB_SX1261_CHIP_TYPE; 6 1 : this->powerMin = RADIOLIB_SX1261_POUT_MIN; 7 1 : this->powerMax = RADIOLIB_SX1261_POUT_MAX; 8 1 : this->paSteps = this->powerMax - this->powerMin + 1; 9 1 : } 10 : 11 1 : int16_t SX1261::setOutputPower(int8_t power) { 12 : // apply offset for external PA 13 1 : int8_t pwr = power; 14 1 : int16_t state = this->applyOutputPowerOffset(RADIOLIB_SX1261_POUT_MIN, &power, &pwr); 15 1 : RADIOLIB_ASSERT(state); 16 : 17 : // get current OCP configuration 18 1 : uint8_t ocp = 0; 19 1 : state = readRegister(RADIOLIB_SX126X_REG_OCP_CONFIGURATION, &ocp, 1); 20 1 : RADIOLIB_ASSERT(state); 21 : 22 : // set PA config 23 0 : uint8_t paDutyCycle = 0x04; 24 0 : if(pwr == RADIOLIB_SX1261_POUT_MAX) { 25 : // for 15 dBm, increase the duty cycle and lowe the power to set 26 : // SX1261/2 datasheet, DS.SX1261-2.W.APP Rev. 2.1 page 78 27 0 : paDutyCycle = 0x06; 28 0 : pwr--; 29 : } 30 0 : state = SX126x::setPaConfig(paDutyCycle, RADIOLIB_SX126X_PA_CONFIG_SX1261, 0x00); 31 0 : RADIOLIB_ASSERT(state); 32 : 33 : // set output power with default 200us ramp 34 0 : state = SX126x::setTxParams(pwr, RADIOLIB_SX126X_PA_RAMP_200U); 35 0 : RADIOLIB_ASSERT(state); 36 : 37 : // restore OCP configuration 38 0 : return(writeRegister(RADIOLIB_SX126X_REG_OCP_CONFIGURATION, &ocp, 1)); 39 : } 40 : 41 : #endif