[RF69] Cleanup private/protected members
This commit is contained in:
parent
935c316f7c
commit
3a5d9b5c32
4 changed files with 35 additions and 32 deletions
|
@ -6,10 +6,6 @@ RF69::RF69(Module* module) : PhysicalLayer(RADIOLIB_RF69_FREQUENCY_STEP_SIZE, RA
|
|||
this->mod = module;
|
||||
}
|
||||
|
||||
Module* RF69::getMod() {
|
||||
return(this->mod);
|
||||
}
|
||||
|
||||
int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t pwr, uint8_t preambleLen) {
|
||||
// set module properties
|
||||
this->mod->init();
|
||||
|
@ -982,6 +978,10 @@ int16_t RF69::setDIOMapping(uint32_t pin, uint32_t value) {
|
|||
return(this->mod->SPIsetRegValue(RADIOLIB_RF69_REG_DIO_MAPPING_2, value, 15 - 2 * pin, 14 - 2 * pin));
|
||||
}
|
||||
|
||||
Module* RF69::getMod() {
|
||||
return(this->mod);
|
||||
}
|
||||
|
||||
int16_t RF69::getChipVersion() {
|
||||
return(this->mod->SPIgetRegValue(RADIOLIB_RF69_REG_VERSION));
|
||||
}
|
||||
|
|
|
@ -490,8 +490,6 @@ class RF69: public PhysicalLayer {
|
|||
*/
|
||||
RF69(Module* module);
|
||||
|
||||
Module* getMod();
|
||||
|
||||
// basic methods
|
||||
|
||||
/*!
|
||||
|
@ -998,15 +996,23 @@ class RF69: public PhysicalLayer {
|
|||
#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
|
||||
protected:
|
||||
#endif
|
||||
Module* mod;
|
||||
Module* getMod();
|
||||
|
||||
#if !RADIOLIB_GODMODE
|
||||
protected:
|
||||
#endif
|
||||
|
||||
float frequency = RADIOLIB_RF69_DEFAULT_FREQ;
|
||||
float bitRate = RADIOLIB_RF69_DEFAULT_BR;
|
||||
float rxBandwidth = RADIOLIB_RF69_DEFAULT_RXBW;
|
||||
|
||||
int16_t config();
|
||||
int16_t setMode(uint8_t mode);
|
||||
|
||||
#if !RADIOLIB_GODMODE
|
||||
private:
|
||||
#endif
|
||||
Module* mod;
|
||||
|
||||
float frequency = RADIOLIB_RF69_DEFAULT_FREQ;
|
||||
bool ookEnabled = false;
|
||||
int16_t tempOffset = 0;
|
||||
int8_t power = RADIOLIB_RF69_DEFAULT_POWER;
|
||||
|
@ -1021,14 +1027,8 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
bool bitSync = true;
|
||||
|
||||
int16_t config();
|
||||
int16_t directMode();
|
||||
int16_t setPacketMode(uint8_t mode, uint8_t len);
|
||||
int16_t setMode(uint8_t mode);
|
||||
|
||||
#if !RADIOLIB_GODMODE
|
||||
private:
|
||||
#endif
|
||||
void clearIRQFlags();
|
||||
void clearFIFO(size_t count);
|
||||
};
|
||||
|
|
|
@ -7,9 +7,10 @@ SX1231::SX1231(Module* mod) : RF69(mod) {
|
|||
|
||||
int16_t SX1231::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
||||
// set module properties
|
||||
this->mod->init();
|
||||
this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput);
|
||||
this->mod->hal->pinMode(this->mod->getRst(), this->mod->hal->GpioModeOutput);
|
||||
Module* mod = this->getMod();
|
||||
mod->init();
|
||||
mod->hal->pinMode(mod->getIrq(), mod->hal->GpioModeInput);
|
||||
mod->hal->pinMode(mod->getRst(), mod->hal->GpioModeOutput);
|
||||
|
||||
// try to find the SX1231 chip
|
||||
uint8_t i = 0;
|
||||
|
@ -21,14 +22,14 @@ int16_t SX1231::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
|||
this->chipRevision = version;
|
||||
} else {
|
||||
RADIOLIB_DEBUG_PRINTLN("SX1231 not found! (%d of 10 tries) RF69_REG_VERSION == 0x%04X, expected 0x0021 / 0x0022 / 0x0023", i + 1, version);
|
||||
this->mod->hal->delay(10);
|
||||
mod->hal->delay(10);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!flagFound) {
|
||||
RADIOLIB_DEBUG_PRINTLN("No SX1231 found!");
|
||||
this->mod->term();
|
||||
mod->term();
|
||||
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
|
||||
}
|
||||
RADIOLIB_DEBUG_PRINTLN("M\tSX1231");
|
||||
|
@ -77,11 +78,11 @@ int16_t SX1231::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
|||
// SX123x V2a only
|
||||
if(this->chipRevision == RADIOLIB_SX123X_CHIP_REVISION_2_A) {
|
||||
// modify default OOK threshold value
|
||||
state = this->mod->SPIsetRegValue(RADIOLIB_SX1231_REG_TEST_OOK, RADIOLIB_SX1231_OOK_DELTA_THRESHOLD);
|
||||
state = mod->SPIsetRegValue(RADIOLIB_SX1231_REG_TEST_OOK, RADIOLIB_SX1231_OOK_DELTA_THRESHOLD);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// enable OCP with 95 mA limit
|
||||
state = this->mod->SPIsetRegValue(RADIOLIB_RF69_REG_OCP, RADIOLIB_RF69_OCP_ON | RADIOLIB_RF69_OCP_TRIM, 4, 0);
|
||||
state = mod->SPIsetRegValue(RADIOLIB_RF69_REG_OCP, RADIOLIB_RF69_OCP_ON | RADIOLIB_RF69_OCP_TRIM, 4, 0);
|
||||
RADIOLIB_ASSERT(state);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,10 @@ SX1233::SX1233(Module* mod) : SX1231(mod) {
|
|||
|
||||
int16_t SX1233::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
||||
// set module properties
|
||||
this->mod->init();
|
||||
this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput);
|
||||
this->mod->hal->pinMode(this->mod->getRst(), this->mod->hal->GpioModeOutput);
|
||||
Module* mod = this->getMod();
|
||||
mod->init();
|
||||
mod->hal->pinMode(mod->getIrq(), mod->hal->GpioModeInput);
|
||||
mod->hal->pinMode(mod->getRst(), mod->hal->GpioModeOutput);
|
||||
|
||||
// try to find the SX1233 chip
|
||||
uint8_t i = 0;
|
||||
|
@ -22,14 +23,14 @@ int16_t SX1233::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
|||
this->chipRevision = version;
|
||||
} else {
|
||||
RADIOLIB_DEBUG_PRINTLN("SX1231 not found! (%d of 10 tries) RF69_REG_VERSION == 0x%04X, expected 0x0021 / 0x0022 / 0x0023", i + 1, version);
|
||||
this->mod->hal->delay(10);
|
||||
mod->hal->delay(10);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!flagFound) {
|
||||
RADIOLIB_DEBUG_PRINTLN("No SX1233 found!");
|
||||
this->mod->term();
|
||||
mod->term();
|
||||
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
|
||||
}
|
||||
RADIOLIB_DEBUG_PRINTLN("M\tSX1233");
|
||||
|
@ -78,11 +79,11 @@ int16_t SX1233::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
|||
// SX123x V2a only
|
||||
if(this->chipRevision == RADIOLIB_SX123X_CHIP_REVISION_2_A) {
|
||||
// modify default OOK threshold value
|
||||
state = this->mod->SPIsetRegValue(RADIOLIB_SX1231_REG_TEST_OOK, RADIOLIB_SX1231_OOK_DELTA_THRESHOLD);
|
||||
state = mod->SPIsetRegValue(RADIOLIB_SX1231_REG_TEST_OOK, RADIOLIB_SX1231_OOK_DELTA_THRESHOLD);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// enable OCP with 95 mA limit
|
||||
state = this->mod->SPIsetRegValue(RADIOLIB_RF69_REG_OCP, RADIOLIB_RF69_OCP_ON | RADIOLIB_RF69_OCP_TRIM, 4, 0);
|
||||
state = mod->SPIsetRegValue(RADIOLIB_RF69_REG_OCP, RADIOLIB_RF69_OCP_ON | RADIOLIB_RF69_OCP_TRIM, 4, 0);
|
||||
RADIOLIB_ASSERT(state);
|
||||
}
|
||||
|
||||
|
@ -109,13 +110,14 @@ int16_t SX1233::setBitRate(float br) {
|
|||
setMode(RADIOLIB_RF69_STANDBY);
|
||||
|
||||
// set PLL bandwidth
|
||||
int16_t state = this->mod->SPIsetRegValue(RADIOLIB_SX1233_REG_TEST_PLL, pllBandwidth, 7, 0);
|
||||
Module* mod = this->getMod();
|
||||
int16_t state = mod->SPIsetRegValue(RADIOLIB_SX1233_REG_TEST_PLL, pllBandwidth, 7, 0);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set bit rate
|
||||
uint16_t bitRate = 32000 / br;
|
||||
state = this->mod->SPIsetRegValue(RADIOLIB_RF69_REG_BITRATE_MSB, (bitRate & 0xFF00) >> 8, 7, 0);
|
||||
state |= this->mod->SPIsetRegValue(RADIOLIB_RF69_REG_BITRATE_LSB, bitRate & 0x00FF, 7, 0);
|
||||
state = mod->SPIsetRegValue(RADIOLIB_RF69_REG_BITRATE_MSB, (bitRate & 0xFF00) >> 8, 7, 0);
|
||||
state |= mod->SPIsetRegValue(RADIOLIB_RF69_REG_BITRATE_LSB, bitRate & 0x00FF, 7, 0);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
this->bitRate = br;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue