Added option to disable "paranoid" SPI mode (enabled by default)

This commit is contained in:
jgromes 2021-02-12 21:03:49 +01:00
parent 4461e9a98e
commit 9a9af85fdc
2 changed files with 41 additions and 30 deletions

View file

@ -390,6 +390,13 @@
//#define RADIOLIB_STATIC_ONLY
/*
* Uncomment to enable "paranoid" SPI mode
* Every write to an SPI register using SPI set function will be verified by a subsequent read operation.
* This improves reliablility, but slightly slows down communication.
*/
#define RADIOLIB_SPI_PARANOID
// set the size of static arrays to use
#if !defined(RADIOLIB_STATIC_ARRAY_SIZE)
#define RADIOLIB_STATIC_ARRAY_SIZE 256

View file

@ -216,6 +216,7 @@ int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t
uint8_t newValue = (currentValue & ~mask) | (value & mask);
SPIwriteRegister(reg, newValue);
#if defined(RADIOLIB_SPI_PARANOID)
// check register value each millisecond until check interval is reached
// some registers need a bit of time to process the change (e.g. SX127X_REG_OP_MODE)
uint32_t start = Module::micros();
@ -249,6 +250,9 @@ int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t
RADIOLIB_DEBUG_PRINTLN();
return(ERR_SPI_WRITE_FAILED);
#else
return(ERR_NONE);
#endif
}
void Module::SPIreadRegisterBurst(uint8_t reg, uint8_t numBytes, uint8_t* inBytes) {