[SX128x] Added force wakeup to standby

This commit is contained in:
jgromes 2023-05-02 21:04:49 +02:00
parent bdc5bb0bba
commit c451765602
2 changed files with 8 additions and 10 deletions

View file

@ -455,20 +455,17 @@ int16_t SX128x::standby() {
return(SX128x::standby(RADIOLIB_SX128X_STANDBY_RC)); return(SX128x::standby(RADIOLIB_SX128X_STANDBY_RC));
} }
int16_t SX128x::standby(uint8_t mode) { int16_t SX128x::standby(uint8_t mode, bool wakeup) {
// set RF switch (if present) // set RF switch (if present)
this->mod->setRfSwitchState(Module::MODE_IDLE); this->mod->setRfSwitchState(Module::MODE_IDLE);
uint8_t data[] = { mode }; if(wakeup) {
int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_STANDBY, data, 1); // pull NSS low to wake up
if(state == RADIOLIB_ERR_NONE) {
return(state);
} else if(state == RADIOLIB_ERR_SPI_CMD_TIMEOUT) {
// the device might be in sleep mode, pull NSS low to wake up and try again
this->mod->hal->digitalWrite(this->mod->getCs(), this->mod->hal->GpioLevelLow); this->mod->hal->digitalWrite(this->mod->getCs(), this->mod->hal->GpioLevelLow);
return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_STANDBY, data, 1));
} }
return(state);
uint8_t data[] = { mode };
return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_STANDBY, data, 1));
} }
void SX128x::setDio1Action(void (*func)(void)) { void SX128x::setDio1Action(void (*func)(void)) {

View file

@ -477,9 +477,10 @@ class SX128x: public PhysicalLayer {
\brief Sets the module to standby mode. \brief Sets the module to standby mode.
\param mode Oscillator to be used in standby mode. Can be set to RADIOLIB_SX128X_STANDBY_RC \param mode Oscillator to be used in standby mode. Can be set to RADIOLIB_SX128X_STANDBY_RC
(13 MHz RC oscillator) or RADIOLIB_SX128X_STANDBY_XOSC (52 MHz external crystal oscillator). (13 MHz RC oscillator) or RADIOLIB_SX128X_STANDBY_XOSC (52 MHz external crystal oscillator).
\param wakeup Whether to force the module to wake up. Setting to true will immediately attempt to wake up the module.
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t standby(uint8_t mode); int16_t standby(uint8_t mode, bool wakeup = false);
// interrupt methods // interrupt methods