kopia lustrzana https://github.com/jgromes/RadioLib
[LR11x0] Move reset to common class
rodzic
482eaea059
commit
0db2156864
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue