[SX126x] Allow custom band calibration
This commit is contained in:
parent
19b61739e6
commit
bf061c655f
5 changed files with 16 additions and 10 deletions
|
@ -51,12 +51,12 @@ int16_t SX1262::setFrequency(float freq) {
|
||||||
return(setFrequency(freq, true));
|
return(setFrequency(freq, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t SX1262::setFrequency(float freq, bool calibrate) {
|
int16_t SX1262::setFrequency(float freq, bool calibrate, float band) {
|
||||||
RADIOLIB_CHECK_RANGE(freq, 150.0, 960.0, RADIOLIB_ERR_INVALID_FREQUENCY);
|
RADIOLIB_CHECK_RANGE(freq, 150.0, 960.0, RADIOLIB_ERR_INVALID_FREQUENCY);
|
||||||
|
|
||||||
// calibrate image rejection - assume band to be the selected frequency +- 4 MHz
|
// calibrate image rejection
|
||||||
if(calibrate) {
|
if(calibrate) {
|
||||||
int16_t state = SX126x::calibrateImage(freq - 4, freq + 4);
|
int16_t state = SX126x::calibrateImage(freq - band, freq + band);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,9 +75,12 @@ class SX1262: public SX126x {
|
||||||
\brief Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz.
|
\brief Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz.
|
||||||
\param freq Carrier frequency to be set in MHz.
|
\param freq Carrier frequency to be set in MHz.
|
||||||
\param calibrate Run image calibration.
|
\param calibrate Run image calibration.
|
||||||
|
\param band Half bandwidth for image calibration. For example,
|
||||||
|
if carrier is 434 MHz and band is set to 4 MHz, then the image will be calibrate
|
||||||
|
for band 430 - 438 MHz. Unused if calibrate is set to false, defaults to 4 MHz
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setFrequency(float freq, bool calibrate);
|
int16_t setFrequency(float freq, bool calibrate, float band = 4);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets output power. Allowed values are in range from -9 to 22 dBm.
|
\brief Sets output power. Allowed values are in range from -9 to 22 dBm.
|
||||||
|
|
|
@ -52,12 +52,12 @@ int16_t SX1268::setFrequency(float freq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \todo integers only (all modules - frequency, data rate, bandwidth etc.)
|
/// \todo integers only (all modules - frequency, data rate, bandwidth etc.)
|
||||||
int16_t SX1268::setFrequency(float freq, bool calibrate) {
|
int16_t SX1268::setFrequency(float freq, bool calibrate, float band) {
|
||||||
RADIOLIB_CHECK_RANGE(freq, 410.0, 810.0, RADIOLIB_ERR_INVALID_FREQUENCY);
|
RADIOLIB_CHECK_RANGE(freq, 410.0, 810.0, RADIOLIB_ERR_INVALID_FREQUENCY);
|
||||||
|
|
||||||
// calibrate image rejection - assume band to be the selected frequency +- 4 MHz
|
// calibrate image rejection
|
||||||
if(calibrate) {
|
if(calibrate) {
|
||||||
int16_t state = SX126x::calibrateImage(freq - 4, freq + 4);
|
int16_t state = SX126x::calibrateImage(freq - band, freq + band);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,12 +71,15 @@ class SX1268: public SX126x {
|
||||||
int16_t setFrequency(float freq);
|
int16_t setFrequency(float freq);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets carrier frequency. Allowed values are in range from 410.0 to 810.0 MHz.
|
\brief Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz.
|
||||||
\param freq Carrier frequency to be set in MHz.
|
\param freq Carrier frequency to be set in MHz.
|
||||||
\param calibrate Run image calibration.
|
\param calibrate Run image calibration.
|
||||||
|
\param band Half bandwidth for image calibration. For example,
|
||||||
|
if carrier is 434 MHz and band is set to 4 MHz, then the image will be calibrate
|
||||||
|
for band 430 - 438 MHz. Unused if calibrate is set to false, defaults to 4 MHz
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setFrequency(float freq, bool calibrate);
|
int16_t setFrequency(float freq, bool calibrate, float band = 4);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets output power. Allowed values are in range from -9 to 22 dBm.
|
\brief Sets output power. Allowed values are in range from -9 to 22 dBm.
|
||||||
|
|
|
@ -1836,7 +1836,7 @@ int16_t SX126x::setRfFrequency(uint32_t frf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t SX126x::calibrateImage(float freqMin, float freqMax) {
|
int16_t SX126x::calibrateImage(float freqMin, float freqMax) {
|
||||||
uint8_t data[] = { (uint8_t)floor((freqMin - 1.0f) / 4.0f), (uint8_t)floor((freqMax - 1.0f) / 4.0f) };
|
uint8_t data[] = { (uint8_t)floor((freqMin - 1.0f) / 4.0f), (uint8_t)ceil((freqMax + 1.0f) / 4.0f) };
|
||||||
int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_CALIBRATE_IMAGE, data, 2);
|
int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_CALIBRATE_IMAGE, data, 2);
|
||||||
|
|
||||||
// if something failed, show the device errors
|
// if something failed, show the device errors
|
||||||
|
|
Loading…
Add table
Reference in a new issue