[SX126x] Allow 15 dBm on SX1261 (#1329)

pull/1335/head^2
jgromes 2024-11-24 09:29:58 +01:00
rodzic 35f18b049b
commit 0bd5bdc896
1 zmienionych plików z 12 dodań i 4 usunięć

Wyświetl plik

@ -16,11 +16,19 @@ int16_t SX1261::setOutputPower(int8_t power) {
RADIOLIB_ASSERT(state);
// set PA config
state = SX126x::setPaConfig(0x04, RADIOLIB_SX126X_PA_CONFIG_SX1261, 0x00);
uint8_t paDutyCycle = 0x04;
int8_t txPwr = power;
if(power == 15) {
// for 15 dBm, increase the duty cycle and lowe the power to set
// SX1261/2 datasheet, DS.SX1261-2.W.APP Rev. 2.1 page 78
paDutyCycle = 0x06;
txPwr--;
}
state = SX126x::setPaConfig(paDutyCycle, RADIOLIB_SX126X_PA_CONFIG_SX1261, 0x00);
RADIOLIB_ASSERT(state);
// set output power with default 200us ramp
state = SX126x::setTxParams(power, RADIOLIB_SX126X_PA_RAMP_200U);
state = SX126x::setTxParams(txPwr, RADIOLIB_SX126X_PA_RAMP_200U);
RADIOLIB_ASSERT(state);
// restore OCP configuration
@ -29,9 +37,9 @@ int16_t SX1261::setOutputPower(int8_t power) {
int16_t SX1261::checkOutputPower(int8_t power, int8_t* clipped) {
if(clipped) {
*clipped = RADIOLIB_MAX(-17, RADIOLIB_MIN(14, power));
*clipped = RADIOLIB_MAX(-17, RADIOLIB_MIN(15, power));
}
RADIOLIB_CHECK_RANGE(power, -17, 14, RADIOLIB_ERR_INVALID_OUTPUT_POWER);
RADIOLIB_CHECK_RANGE(power, -17, 15, RADIOLIB_ERR_INVALID_OUTPUT_POWER);
return(RADIOLIB_ERR_NONE);
}