From 0db2156864d61b5cb156a535351337c30585cccb Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Nov 2025 17:12:18 +0000 Subject: [PATCH] [LR11x0] Move reset to common class --- src/modules/LR11x0/LR11x0.cpp | 23 ----------------------- src/modules/LR11x0/LR11x0.h | 6 ------ src/modules/LR11x0/LR_common.cpp | 23 +++++++++++++++++++++++ src/modules/LR11x0/LR_common.h | 6 ++++++ 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/modules/LR11x0/LR11x0.cpp b/src/modules/LR11x0/LR11x0.cpp index fe569196..cb02c511 100644 --- a/src/modules/LR11x0/LR11x0.cpp +++ b/src/modules/LR11x0/LR11x0.cpp @@ -150,29 +150,6 @@ int16_t LR11x0::beginGNSS(uint8_t constellations, float tcxoVoltage) { return(RADIOLIB_ERR_NONE); } -int16_t LR11x0::reset() { - // run the reset sequence - this->mod->hal->pinMode(this->mod->getRst(), this->mod->hal->GpioModeOutput); - this->mod->hal->digitalWrite(this->mod->getRst(), this->mod->hal->GpioLevelLow); - this->mod->hal->delay(10); - this->mod->hal->digitalWrite(this->mod->getRst(), this->mod->hal->GpioLevelHigh); - - // the typical transition duration should be 273 ms - this->mod->hal->delay(300); - - // wait for BUSY to go low - RadioLibTime_t start = this->mod->hal->millis(); - while(this->mod->hal->digitalRead(this->mod->getGpio())) { - this->mod->hal->yield(); - if(this->mod->hal->millis() - start >= 3000) { - RADIOLIB_DEBUG_BASIC_PRINTLN("BUSY pin timeout after reset!"); - return(RADIOLIB_ERR_SPI_CMD_TIMEOUT); - } - } - - return(RADIOLIB_ERR_NONE); -} - int16_t LR11x0::transmit(const uint8_t* data, size_t len, uint8_t addr) { // set mode to standby int16_t state = standby(); diff --git a/src/modules/LR11x0/LR11x0.h b/src/modules/LR11x0/LR11x0.h index 63a86ab7..d7bc01d0 100644 --- a/src/modules/LR11x0/LR11x0.h +++ b/src/modules/LR11x0/LR11x0.h @@ -111,12 +111,6 @@ class LR11x0: public PhysicalLayer, public LRxxxx { */ int16_t beginGNSS(uint8_t constellations = RADIOLIB_LR11X0_GNSS_CONSTELLATION_GPS | RADIOLIB_LR11X0_GNSS_CONSTELLATION_BEIDOU, float tcxoVoltage = 1.6); - /*! - \brief Reset method. Will reset the chip to the default state using RST pin. - \returns \ref status_codes - */ - int16_t reset(); - /*! \brief Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. diff --git a/src/modules/LR11x0/LR_common.cpp b/src/modules/LR11x0/LR_common.cpp index 325a4ec1..55fac7da 100644 --- a/src/modules/LR11x0/LR_common.cpp +++ b/src/modules/LR11x0/LR_common.cpp @@ -6,6 +6,29 @@ LRxxxx::LRxxxx(Module* mod) { this->mod = mod; } +int16_t LRxxxx::reset() { + // run the reset sequence + this->mod->hal->pinMode(this->mod->getRst(), this->mod->hal->GpioModeOutput); + this->mod->hal->digitalWrite(this->mod->getRst(), this->mod->hal->GpioLevelLow); + this->mod->hal->delay(10); + this->mod->hal->digitalWrite(this->mod->getRst(), this->mod->hal->GpioLevelHigh); + + // the typical transition duration should be 273 ms + this->mod->hal->delay(300); + + // wait for BUSY to go low + RadioLibTime_t start = this->mod->hal->millis(); + while(this->mod->hal->digitalRead(this->mod->getGpio())) { + this->mod->hal->yield(); + if(this->mod->hal->millis() - start >= 3000) { + RADIOLIB_DEBUG_BASIC_PRINTLN("BUSY pin timeout after reset!"); + return(RADIOLIB_ERR_SPI_CMD_TIMEOUT); + } + } + + return(RADIOLIB_ERR_NONE); +} + int16_t LRxxxx::getStatus(uint8_t* stat1, uint8_t* stat2, uint32_t* irq) { uint8_t buff[6] = { 0 }; diff --git a/src/modules/LR11x0/LR_common.h b/src/modules/LR11x0/LR_common.h index c7f6623f..972869c6 100644 --- a/src/modules/LR11x0/LR_common.h +++ b/src/modules/LR11x0/LR_common.h @@ -45,6 +45,12 @@ class LRxxxx { public: LRxxxx(Module* mod); + /*! + \brief Reset method. Will reset the chip to the default state using RST pin. + \returns \ref status_codes + */ + int16_t reset(); + protected: // a lot of SPI commands have the same structure and arguments on both LR11xx as well as LR2021 // the only difference is the 16-bit command code - however, having everything in this base class