Skip to content

Commit

Permalink
Check for RADIOLIB_SPI_PARANOID = 1 rather than just defined (#883)
Browse files Browse the repository at this point in the history
* Update BuildOpt.h to set RADIOLIB_SPI_PARANOID to 1 by default

* Update Module.cpp to check for RADIOLIB_SPI_PARANOID set to 1
  • Loading branch information
jp-bennett authored Nov 27, 2023
1 parent b6f6718 commit f4938ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/BuildOpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@
#endif

/*
* Uncomment to enable "paranoid" SPI mode
* Comment to disable "paranoid" SPI mode, or set RADIOLIB_SPI_PARANOID to 0
* Every write to an SPI register using SPI set function will be verified by a subsequent read operation.
* This improves reliability, but slightly slows down communication.
* Note: Enabled by default.
*/
#if !defined(RADIOLIB_SPI_PARANOID)
#define RADIOLIB_SPI_PARANOID
#define RADIOLIB_SPI_PARANOID 1
#endif

/*
Expand Down
4 changes: 2 additions & 2 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int16_t Module::SPIsetRegValue(uint16_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)
#if 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 = this->hal->micros();
Expand Down Expand Up @@ -240,7 +240,7 @@ int16_t Module::SPIwriteStream(uint8_t* cmd, uint8_t cmdLen, uint8_t* data, size
int16_t Module::SPIcheckStream() {
int16_t state = RADIOLIB_ERR_NONE;

#if defined(RADIOLIB_SPI_PARANOID)
#if RADIOLIB_SPI_PARANOID
// get the status
uint8_t spiStatus = 0;
uint8_t cmd = this->SPIstatusCommand;
Expand Down

0 comments on commit f4938ea

Please sign in to comment.