[SX126x] Added force wakeup to standby (#740)
This commit is contained in:
parent
c451765602
commit
89f909fc6e
2 changed files with 8 additions and 10 deletions
|
@ -449,20 +449,17 @@ int16_t SX126x::standby() {
|
|||
return(SX126x::standby(RADIOLIB_SX126X_STANDBY_RC));
|
||||
}
|
||||
|
||||
int16_t SX126x::standby(uint8_t mode) {
|
||||
int16_t SX126x::standby(uint8_t mode, bool wakeup) {
|
||||
// set RF switch (if present)
|
||||
this->mod->setRfSwitchState(Module::MODE_IDLE);
|
||||
|
||||
uint8_t data[] = { mode };
|
||||
int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_SET_STANDBY, data, 1);
|
||||
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
|
||||
if(wakeup) {
|
||||
// pull NSS low to wake up
|
||||
this->mod->hal->digitalWrite(this->mod->getCs(), this->mod->hal->GpioLevelLow);
|
||||
return(this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_SET_STANDBY, data, 1));
|
||||
}
|
||||
return(state);
|
||||
|
||||
uint8_t data[] = { mode };
|
||||
return(this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_SET_STANDBY, data, 1));
|
||||
}
|
||||
|
||||
void SX126x::setDio1Action(void (*func)(void)) {
|
||||
|
|
|
@ -555,9 +555,10 @@ class SX126x: public PhysicalLayer {
|
|||
\brief Sets the module to standby mode.
|
||||
\param mode Oscillator to be used in standby mode. Can be set to RADIOLIB_SX126X_STANDBY_RC (13 MHz RC oscillator)
|
||||
or RADIOLIB_SX126X_STANDBY_XOSC (32 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
|
||||
*/
|
||||
int16_t standby(uint8_t mode);
|
||||
int16_t standby(uint8_t mode, bool wakeup = true);
|
||||
|
||||
// interrupt methods
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue