Fixed RXPS for LR1110

This commit is contained in:
Kevin Le committed 2026-08-18 09:29:12 +07:00
1 parent a5a519ac31
commit 307bc938b5
4 files changed
+7 -81

No files matched your search

+6 -17
View File
@@ -71,6 +71,8 @@ class CustomLR1110 : public LR1110 {
int16_t state = standby(RADIOLIB_LR11X0_STANDBY_RC);
RADIOLIB_ASSERT(state);
// Semtech requires the RC standby/RTC setup before SetRxDutyCycle.
state = configLfClock(RADIOLIB_LR11X0_LF_CLK_RC | RADIOLIB_LR11X0_LF_BUSY_RELEASE_ENABLED);
RADIOLIB_ASSERT(state);
RadioModeConfig_t cfg = {
.receive = {
.timeout = RADIOLIB_LR11X0_RX_TIMEOUT_INF,
@@ -79,23 +81,10 @@ class CustomLR1110 : public LR1110 {
.len = 0,
}
};
return runRxPowerSavingArmTransaction(
[this]() {
return configLfClock(
RADIOLIB_LR11X0_LF_CLK_RC | RADIOLIB_LR11X0_LF_BUSY_RELEASE_ENABLED);
},
[this, &cfg]() {
return this->stageMode(RADIOLIB_RADIO_MODE_RX, &cfg);
},
[this, rxPeriodRaw, sleepPeriodRaw]() {
return this->setRxDutyCycle(
rxPeriodRaw, sleepPeriodRaw, RADIOLIB_LR11X0_RX_DUTY_CYCLE_MODE_RX);
},
[this]() {
// Preserve the arm error even if this best-effort rollback fails.
// A failed ConfigLfClock response may still mean the command ran.
restoreLfClock();
});
state = stageMode(RADIOLIB_RADIO_MODE_RX, &cfg);
RADIOLIB_ASSERT(state);
return setRxDutyCycle(rxPeriodRaw, sleepPeriodRaw, RADIOLIB_LR11X0_RX_DUTY_CYCLE_MODE_RX);
}
int16_t setRxBoostedGainMode(bool en) {
+1 -3
View File
@@ -58,9 +58,7 @@ protected:
}
int16_t stopDutyCycleHardware() override {
int16_t standby_err = _radio->standby();
int16_t lf_err = ((CustomLR1110 *)_radio)->restoreLfClock();
return standby_err != RADIOLIB_ERR_NONE ? standby_err : lf_err;
return _radio->standby();
}
public:
-23
View File
@@ -29,29 +29,6 @@ public:
uint8_t consecutiveFailures() const { return _consecutive_failures; }
};
// Runs the part of a hardware arm sequence that starts by changing persistent
// radio configuration. Every failing step rolls that configuration back, while
// the original arm error remains the result returned to the caller.
template <typename Configure, typename Stage, typename Arm, typename Rollback>
int16_t runRxPowerSavingArmTransaction(Configure configure, Stage stage,
Arm arm, Rollback rollback) {
int16_t state = configure();
if (state != 0) {
rollback();
return state;
}
state = stage();
if (state != 0) {
rollback();
return state;
}
state = arm();
if (state != 0) rollback();
return state;
}
struct RxPowerSavingConfig {
uint8_t enabled = 0;
uint32_t rx_us = RX_POWERSAVING_DEFAULT_RX_US;