[MOD] Decreased default SPI timeout to 1000 ms

This commit is contained in:
jgromes 2023-04-24 18:25:42 +02:00
parent a22a4df88f
commit 044b4789b2
2 changed files with 10 additions and 7 deletions

View file

@ -105,7 +105,7 @@ void Module::SPIreadRegisterBurst(uint16_t reg, size_t numBytes, uint8_t* inByte
SPItransfer(SPIreadCommand, reg, NULL, inBytes, numBytes);
} else {
uint8_t cmd[] = { SPIreadCommand, (uint8_t)((reg >> 8) & 0xFF), (uint8_t)(reg & 0xFF) };
SPItransferStream(cmd, 3, false, NULL, inBytes, numBytes, true, 5000);
SPItransferStream(cmd, 3, false, NULL, inBytes, numBytes, true, RADIOLIB_MODULE_SPI_TIMEOUT);
}
}
@ -115,7 +115,7 @@ uint8_t Module::SPIreadRegister(uint16_t reg) {
SPItransfer(SPIreadCommand, reg, NULL, &resp, 1);
} else {
uint8_t cmd[] = { SPIreadCommand, (uint8_t)((reg >> 8) & 0xFF), (uint8_t)(reg & 0xFF) };
SPItransferStream(cmd, 3, false, NULL, &resp, 1, true, 5000);
SPItransferStream(cmd, 3, false, NULL, &resp, 1, true, RADIOLIB_MODULE_SPI_TIMEOUT);
}
return(resp);
}
@ -125,7 +125,7 @@ void Module::SPIwriteRegisterBurst(uint16_t reg, uint8_t* data, size_t numBytes)
SPItransfer(SPIwriteCommand, reg, data, NULL, numBytes);
} else {
uint8_t cmd[] = { SPIwriteCommand, (uint8_t)((reg >> 8) & 0xFF), (uint8_t)(reg & 0xFF) };
SPItransferStream(cmd, 3, true, data, NULL, numBytes, true, 5000);
SPItransferStream(cmd, 3, true, data, NULL, numBytes, true, RADIOLIB_MODULE_SPI_TIMEOUT);
}
}
@ -134,7 +134,7 @@ void Module::SPIwriteRegister(uint16_t reg, uint8_t data) {
SPItransfer(SPIwriteCommand, reg, &data, NULL, 1);
} else {
uint8_t cmd[] = { SPIwriteCommand, (uint8_t)((reg >> 8) & 0xFF), (uint8_t)(reg & 0xFF) };
SPItransferStream(cmd, 3, true, &data, NULL, 1, true, 5000);
SPItransferStream(cmd, 3, true, &data, NULL, 1, true, RADIOLIB_MODULE_SPI_TIMEOUT);
}
}
@ -193,7 +193,7 @@ int16_t Module::SPIreadStream(uint8_t cmd, uint8_t* data, size_t numBytes, bool
int16_t Module::SPIreadStream(uint8_t* cmd, uint8_t cmdLen, uint8_t* data, size_t numBytes, bool waitForGpio, bool verify) {
// send the command
int16_t state = this->SPItransferStream(cmd, cmdLen, false, NULL, data, numBytes, waitForGpio, 5000);
int16_t state = this->SPItransferStream(cmd, cmdLen, false, NULL, data, numBytes, waitForGpio, RADIOLIB_MODULE_SPI_TIMEOUT);
RADIOLIB_ASSERT(state);
// check the status
@ -210,7 +210,7 @@ int16_t Module::SPIwriteStream(uint8_t cmd, uint8_t* data, size_t numBytes, bool
int16_t Module::SPIwriteStream(uint8_t* cmd, uint8_t cmdLen, uint8_t* data, size_t numBytes, bool waitForGpio, bool verify) {
// send the command
int16_t state = this->SPItransferStream(cmd, cmdLen, true, data, NULL, numBytes, waitForGpio, 5000);
int16_t state = this->SPItransferStream(cmd, cmdLen, true, data, NULL, numBytes, waitForGpio, RADIOLIB_MODULE_SPI_TIMEOUT);
RADIOLIB_ASSERT(state);
// check the status
@ -228,7 +228,7 @@ int16_t Module::SPIcheckStream() {
// get the status
uint8_t spiStatus = 0;
uint8_t cmd = this->SPIstatusCommand;
state = this->SPItransferStream(&cmd, 1, false, NULL, &spiStatus, 1, true, 5000);
state = this->SPItransferStream(&cmd, 1, false, NULL, &spiStatus, 1, true, RADIOLIB_MODULE_SPI_TIMEOUT);
RADIOLIB_ASSERT(state);
// translate to RadioLib status code

View file

@ -20,6 +20,9 @@
*/
#define END_OF_MODE_TABLE { Module::MODE_END_OF_TABLE, {} }
// default timeout for SPI transfers
#define RADIOLIB_MODULE_SPI_TIMEOUT (1000)
/*!
\class Module
\brief Implements all common low-level methods to control the wireless module.