[SX126x] Remove standby before data read (#703)
This commit is contained in:
parent
c8b28887ee
commit
cb385f5946
3 changed files with 13 additions and 13 deletions
|
@ -74,7 +74,6 @@ void setup() {
|
|||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
|
@ -142,8 +141,5 @@ void loop() {
|
|||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -646,12 +646,10 @@ int16_t SX126x::startReceiveCommon(uint32_t timeout, uint16_t irqFlags, uint16_t
|
|||
}
|
||||
|
||||
int16_t SX126x::readData(uint8_t* data, size_t len) {
|
||||
// set mode to standby
|
||||
int16_t state = standby();
|
||||
|
||||
// this method may get called from receive() after Rx timeout
|
||||
// if that's the case, the standby call will return "SPI command timeout error"
|
||||
// if that's the case, the first call will return "SPI command timeout error"
|
||||
// check the IRQ to be sure this really originated from timeout event
|
||||
int16_t state = _mod->SPIcheckStream();
|
||||
if((state == RADIOLIB_ERR_SPI_CMD_TIMEOUT) && (getIrqStatus() & RADIOLIB_SX126X_IRQ_TIMEOUT)) {
|
||||
// this is definitely Rx timeout
|
||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||
|
@ -676,6 +674,10 @@ int16_t SX126x::readData(uint8_t* data, size_t len) {
|
|||
state = readBuffer(data, length);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// reset the base addresses
|
||||
state = setBufferBaseAddress();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// clear interrupt flags
|
||||
state = clearIrqStatus();
|
||||
|
||||
|
@ -1674,8 +1676,8 @@ int16_t SX126x::writeBuffer(uint8_t* data, uint8_t numBytes, uint8_t offset) {
|
|||
return(_mod->SPIwriteStream(cmd, 2, data, numBytes));
|
||||
}
|
||||
|
||||
int16_t SX126x::readBuffer(uint8_t* data, uint8_t numBytes) {
|
||||
uint8_t cmd[] = { RADIOLIB_SX126X_CMD_READ_BUFFER, RADIOLIB_SX126X_CMD_NOP };
|
||||
int16_t SX126x::readBuffer(uint8_t* data, uint8_t numBytes, uint8_t offset) {
|
||||
uint8_t cmd[] = { RADIOLIB_SX126X_CMD_READ_BUFFER, offset };
|
||||
return(_mod->SPIreadStream(cmd, 2, data, numBytes));
|
||||
}
|
||||
|
||||
|
|
|
@ -630,8 +630,10 @@ class SX126x: public PhysicalLayer {
|
|||
/*!
|
||||
\brief Interrupt-driven receive method. DIO1 will be activated when full packet is received.
|
||||
|
||||
\param timeout Raw timeout value, expressed as multiples of 15.625 us. Defaults to RADIOLIB_SX126X_RX_TIMEOUT_INF for infinite timeout (Rx continuous mode), set to RADIOLIB_SX126X_RX_TIMEOUT_NONE for no timeout (Rx single mode).
|
||||
If timeout other than infinite is set, signal will be generated on DIO1.
|
||||
\param timeout Receive mode type and/or raw timeout value, expressed as multiples of 15.625 us.
|
||||
When set to RADIOLIB_SX126X_RX_TIMEOUT_INF, the timeout will be infinite and the device will remain in Rx mode until explicitly commanded to stop (Rx continuous mode).
|
||||
When set to RADIOLIB_SX126X_RX_TIMEOUT_NONE, there will be no timeout and the device will return to standby when a packet is received (Rx single mode).
|
||||
For any other value, timeout will be applied and signal will be generated on DIO1 for conditions defined by irqFlags and irqMask.
|
||||
|
||||
\param irqFlags Sets the IRQ flags, defaults to RADIOLIB_SX126X_IRQ_RX_DEFAULT.
|
||||
|
||||
|
@ -1145,7 +1147,7 @@ class SX126x: public PhysicalLayer {
|
|||
int16_t writeRegister(uint16_t addr, uint8_t* data, uint8_t numBytes);
|
||||
int16_t readRegister(uint16_t addr, uint8_t* data, uint8_t numBytes);
|
||||
int16_t writeBuffer(uint8_t* data, uint8_t numBytes, uint8_t offset = 0x00);
|
||||
int16_t readBuffer(uint8_t* data, uint8_t numBytes);
|
||||
int16_t readBuffer(uint8_t* data, uint8_t numBytes, uint8_t offset = 0x00);
|
||||
int16_t setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask = RADIOLIB_SX126X_IRQ_NONE, uint16_t dio3Mask = RADIOLIB_SX126X_IRQ_NONE);
|
||||
virtual int16_t clearIrqStatus(uint16_t clearIrqParams = RADIOLIB_SX126X_IRQ_ALL);
|
||||
int16_t setRfFrequency(uint32_t frf);
|
||||
|
|
Loading…
Add table
Reference in a new issue