Merge branch 'master' into feature/implement_AFC_control

This commit is contained in:
Libor Tomsik 2021-04-16 12:14:38 +02:00
commit d29e3609b4
No known key found for this signature in database
GPG key ID: 29CB8B18FAB6FBDB
4 changed files with 12 additions and 5 deletions

View file

@ -206,7 +206,7 @@ int16_t Module::SPIgetRegValue(uint8_t reg, uint8_t msb, uint8_t lsb) {
return(maskedValue);
}
int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t lsb, uint8_t checkInterval) {
int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t lsb, uint8_t checkInterval, uint8_t checkMask) {
if((msb > 7) || (lsb > 7) || (lsb > msb)) {
return(ERR_INVALID_BIT_RANGE);
}
@ -223,7 +223,7 @@ int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t
uint8_t readValue = 0x00;
while(Module::micros() - start < (checkInterval * 1000)) {
readValue = SPIreadRegister(reg);
if(readValue == newValue) {
if((readValue & checkMask) == (newValue & checkMask)) {
// check passed, we can stop the loop
return(ERR_NONE);
}

View file

@ -238,9 +238,11 @@ class Module {
\param checkInterval Number of milliseconds between register writing and verification reading. Some registers need up to 10ms to process the change.
\param checkMask Mask of bits to check, only bits set to 1 will be verified.
\returns \ref status_codes
*/
int16_t SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2);
int16_t SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2, uint8_t checkMask = 0xFF);
/*!
\brief SPI burst read method.

View file

@ -1235,7 +1235,12 @@ bool SX127x::findChip(uint8_t ver) {
}
int16_t SX127x::setMode(uint8_t mode) {
return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, mode, 2, 0, 5));
uint8_t checkMask = 0xFF;
if((getActiveModem() == SX127X_FSK_OOK) && (mode == SX127X_RX)) {
// disable checking of RX bit in FSK RX mode, as it sometimes seem to fail (#276)
checkMask = 0xFE;
}
return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, mode, 2, 0, 5, checkMask));
}
int16_t SX127x::getActiveModem() {

View file

@ -10,7 +10,7 @@ ITA2String::ITA2String(char c) {
ITA2String::ITA2String(const char* str) {
_len = strlen(str);
_str = new char[_len];
_str = new char[_len + 1];
strcpy(_str, str);
_ita2Len = 0;
}