[SX126x] Changed shaping datatype to uint8_t

This commit is contained in:
jgromes 2020-07-06 08:52:48 +02:00
parent 263410ffb1
commit 5aff492323
6 changed files with 31 additions and 24 deletions

View file

@ -23,7 +23,7 @@ int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync
return(state);
}
int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO) {
int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) {
// execute common part
int16_t state = SX126x::beginFSK(br, freqDev, rxBw, currentLimit, preambleLength, dataShaping, tcxoVoltage, useRegulatorLDO);
RADIOLIB_ASSERT(state);

View file

@ -75,7 +75,7 @@ class SX1262: public SX126x {
\returns \ref status_codes
*/
int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, float dataShaping = 0.5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
// configuration methods

View file

@ -23,7 +23,7 @@ int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync
return(state);
}
int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO) {
int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) {
// execute common part
int16_t state = SX126x::beginFSK(br, freqDev, rxBw, currentLimit, preambleLength, dataShaping, tcxoVoltage, useRegulatorLDO);
RADIOLIB_ASSERT(state);

View file

@ -69,13 +69,13 @@ class SX1268: public SX126x {
\parma preambleLength FSK preamble length in bits. Defaults to 16 bits.
\param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5.
\param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to RADIOLIB_SHAPING_0_5.
\param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
\returns \ref status_codes
*/
int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, float dataShaping = 0.5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
// configuration methods

View file

@ -75,7 +75,7 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float
return(state);
}
int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO) {
int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) {
// set module properties
_mod->init(RADIOLIB_USE_SPI);
Module::pinMode(_mod->getIrq(), INPUT);
@ -826,26 +826,31 @@ int16_t SX126x::setRxBandwidth(float rxBw) {
return(setModulationParamsFSK(_br, _pulseShape, _rxBw, _freqDev));
}
int16_t SX126x::setDataShaping(float sh) {
int16_t SX126x::setDataShaping(uint8_t sh) {
// check active modem
if(getPacketType() != SX126X_PACKET_TYPE_GFSK) {
return(ERR_WRONG_MODEM);
}
// check allowed values
sh *= 10.0;
if(abs(sh - 0.0) <= 0.001) {
_pulseShape = SX126X_GFSK_FILTER_NONE;
} else if(abs(sh - 3.0) <= 0.001) {
_pulseShape = SX126X_GFSK_FILTER_GAUSS_0_3;
} else if(abs(sh - 5.0) <= 0.001) {
_pulseShape = SX126X_GFSK_FILTER_GAUSS_0_5;
} else if(abs(sh - 7.0) <= 0.001) {
_pulseShape = SX126X_GFSK_FILTER_GAUSS_0_7;
} else if(abs(sh - 10.0) <= 0.001) {
_pulseShape = SX126X_GFSK_FILTER_GAUSS_1;
} else {
return(ERR_INVALID_DATA_SHAPING);
// set data shaping
switch(sh) {
case RADIOLIB_SHAPING_NONE:
_pulseShape = SX126X_GFSK_FILTER_NONE;
break;
case RADIOLIB_SHAPING_0_3:
_pulseShape = SX126X_GFSK_FILTER_GAUSS_0_3;
break;
case RADIOLIB_SHAPING_0_5:
_pulseShape = SX126X_GFSK_FILTER_GAUSS_0_5;
break;
case RADIOLIB_SHAPING_0_7:
_pulseShape = SX126X_GFSK_FILTER_GAUSS_0_7;
break;
case RADIOLIB_SHAPING_1_0:
_pulseShape = SX126X_GFSK_FILTER_GAUSS_1;
break;
default:
return(ERR_INVALID_DATA_SHAPING);
}
// update modulation parameters

View file

@ -400,7 +400,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes
*/
int16_t beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO = false);
int16_t beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO = false);
/*!
\brief Reset method. Will reset the chip to the default state using RST pin.
@ -653,13 +653,15 @@ class SX126x: public PhysicalLayer {
int16_t setRxBandwidth(float rxBw);
/*!
\brief Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are 0.3, 0.5, 0.7 and 1.0. Set to 0 to disable shaping.
\brief Sets time-bandwidth product of Gaussian filter applied for shaping.
Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5, RADIOLIB_SHAPING_0_7 or RADIOLIB_SHAPING_1_0.
Set to RADIOLIB_SHAPING_NONE to disable data shaping.
\param sh Time-bandwidth product of Gaussian filter to be set.
\returns \ref status_codes
*/
int16_t setDataShaping(float sh) override;
int16_t setDataShaping(uint8_t sh) override;
/*!
\brief Sets FSK sync word in the form of array of up to 8 bytes.