[RFM9x] Added assert macro

This commit is contained in:
jgromes 2020-01-13 16:37:01 +01:00
parent 751fb6431c
commit be701ed120
3 changed files with 34 additions and 68 deletions

View file

@ -7,46 +7,29 @@ RFM95::RFM95(Module* mod) : SX1278(mod) {
int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) {
// execute common part // execute common part
int16_t state = SX127x::begin(RFM95_CHIP_VERSION, syncWord, currentLimit, preambleLength); int16_t state = SX127x::begin(RFM95_CHIP_VERSION, syncWord, currentLimit, preambleLength);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
// configure settings not accessible by API // configure settings not accessible by API
state = config(); state = config();
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
// configure publicly accessible settings // configure publicly accessible settings
state = setFrequency(freq); state = setFrequency(freq);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setBandwidth(bw); state = setBandwidth(bw);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setSpreadingFactor(sf); state = setSpreadingFactor(sf);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setCodingRate(cr); state = setCodingRate(cr);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setOutputPower(power); state = setOutputPower(power);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setGain(gain); state = setGain(gain);
if(state != ERR_NONE) {
return(state);
}
return(state); return(state);
} }

View file

@ -7,46 +7,29 @@ RFM96::RFM96(Module* mod) : SX1278(mod) {
int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) {
// execute common part // execute common part
int16_t state = SX127x::begin(RFM9X_CHIP_VERSION, syncWord, currentLimit, preambleLength); int16_t state = SX127x::begin(RFM9X_CHIP_VERSION, syncWord, currentLimit, preambleLength);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
// configure settings not accessible by API // configure settings not accessible by API
state = config(); state = config();
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
// configure publicly accessible settings // configure publicly accessible settings
state = setFrequency(freq); state = setFrequency(freq);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setBandwidth(bw); state = setBandwidth(bw);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setSpreadingFactor(sf); state = setSpreadingFactor(sf);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setCodingRate(cr); state = setCodingRate(cr);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setOutputPower(power); state = setOutputPower(power);
if(state != ERR_NONE) { RADIOLIB_ASSERT(state);
return(state);
}
state = setGain(gain); state = setGain(gain);
if(state != ERR_NONE) {
return(state);
}
return(state); return(state);
} }