LCOV - code coverage report
Current view: top level - src/modules/SX126x - SX1261.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 13 24 54.2 %
Date: 2026-02-22 10:42:45 Functions: 3 3 100.0 %

          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 : }
       7             : 
       8           1 : int16_t SX1261::setOutputPower(int8_t power) {
       9             :   // check if power value is configurable
      10           1 :   int16_t state = checkOutputPower(power, NULL);
      11           1 :   RADIOLIB_ASSERT(state);
      12             : 
      13             :   // get current OCP configuration
      14           1 :   uint8_t ocp = 0;
      15           1 :   state = readRegister(RADIOLIB_SX126X_REG_OCP_CONFIGURATION, &ocp, 1);
      16           1 :   RADIOLIB_ASSERT(state);
      17             : 
      18             :   // set PA config
      19           0 :   uint8_t paDutyCycle = 0x04;
      20           0 :   int8_t txPwr = power;
      21           0 :   if(power == 15) {
      22             :     // for 15 dBm, increase the duty cycle and lowe the power to set
      23             :     // SX1261/2 datasheet, DS.SX1261-2.W.APP Rev. 2.1 page 78
      24           0 :     paDutyCycle = 0x06;
      25           0 :     txPwr--;
      26             :   }
      27           0 :   state = SX126x::setPaConfig(paDutyCycle, RADIOLIB_SX126X_PA_CONFIG_SX1261, 0x00);
      28           0 :   RADIOLIB_ASSERT(state);
      29             : 
      30             :   // set output power with default 200us ramp
      31           0 :   state = SX126x::setTxParams(txPwr, RADIOLIB_SX126X_PA_RAMP_200U);
      32           0 :   RADIOLIB_ASSERT(state);
      33             : 
      34             :   // restore OCP configuration
      35           0 :   return(writeRegister(RADIOLIB_SX126X_REG_OCP_CONFIGURATION, &ocp, 1));
      36             : }
      37             : 
      38           2 : int16_t SX1261::checkOutputPower(int8_t power, int8_t* clipped) {
      39           2 :   if(clipped) {
      40           0 :     *clipped = RADIOLIB_MAX(-17, RADIOLIB_MIN(15, power));
      41             :   }
      42           2 :   RADIOLIB_CHECK_RANGE(power, -17, 15, RADIOLIB_ERR_INVALID_OUTPUT_POWER);
      43           2 :   return(RADIOLIB_ERR_NONE);
      44             : }
      45             : 
      46             : #endif

Generated by: LCOV version 1.14