[SX126x] Fixed IQ inversion not caching (#731)

This commit is contained in:
jgromes 2023-04-17 19:10:26 +02:00
parent 88549baf83
commit 2e8d0ae8a3
2 changed files with 11 additions and 9 deletions

View file

@ -481,7 +481,7 @@ int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
int16_t state = RADIOLIB_ERR_NONE;
uint8_t modem = getPacketType();
if(modem == RADIOLIB_SX126X_PACKET_TYPE_LORA) {
state = setPacketParams(_preambleLength, _crcType, len, _headerType);
state = setPacketParams(_preambleLength, _crcType, len, _headerType, _invertIQ);
} else if(modem == RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
state = setPacketParamsFSK(_preambleLengthFSK, _crcTypeFSK, _syncWordLength, _addrComp, _whitening, _packetType, len);
} else {
@ -629,7 +629,7 @@ int16_t SX126x::startReceiveCommon(uint32_t timeout, uint16_t irqFlags, uint16_t
// restore original packet length
uint8_t modem = getPacketType();
if(modem == RADIOLIB_SX126X_PACKET_TYPE_LORA) {
state = setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType);
state = setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType, _invertIQ);
} else if(modem == RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
state = setPacketParamsFSK(_preambleLengthFSK, _crcTypeFSK, _syncWordLength, _addrComp, _whitening, _packetType);
} else {
@ -842,7 +842,7 @@ int16_t SX126x::setPreambleLength(uint16_t preambleLength) {
uint8_t modem = getPacketType();
if(modem == RADIOLIB_SX126X_PACKET_TYPE_LORA) {
_preambleLength = preambleLength;
return(setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType));
return(setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType, _invertIQ));
} else if(modem == RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
_preambleLengthFSK = preambleLength;
return(setPacketParamsFSK(_preambleLengthFSK, _crcTypeFSK, _syncWordLength, _addrComp, _whitening, _packetType));
@ -1171,7 +1171,7 @@ int16_t SX126x::setCRC(uint8_t len, uint16_t initial, uint16_t polynomial, bool
_crcType = RADIOLIB_SX126X_LORA_CRC_OFF;
}
return(setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType));
return(setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType, _invertIQ));
}
return(RADIOLIB_ERR_UNKNOWN);
@ -1420,12 +1420,13 @@ int16_t SX126x::invertIQ(bool invertIQ) {
return(RADIOLIB_ERR_WRONG_MODEM);
}
uint8_t invert = RADIOLIB_SX126X_LORA_IQ_STANDARD;
if(invertIQ) {
invert = RADIOLIB_SX126X_LORA_IQ_INVERTED;
_invertIQ = RADIOLIB_SX126X_LORA_IQ_INVERTED;
} else {
_invertIQ = RADIOLIB_SX126X_LORA_IQ_STANDARD;
}
return(setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType, invert));
return(setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType, _invertIQ));
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
@ -1745,7 +1746,7 @@ int16_t SX126x::setHeaderType(uint8_t headerType, size_t len) {
}
// set requested packet mode
int16_t state = setPacketParams(_preambleLength, _crcType, len, headerType);
int16_t state = setPacketParams(_preambleLength, _crcType, len, headerType, _invertIQ);
RADIOLIB_ASSERT(state);
// update cached value

View file

@ -1156,7 +1156,7 @@ class SX126x: public PhysicalLayer {
int16_t setTxParams(uint8_t power, uint8_t rampTime = RADIOLIB_SX126X_PA_RAMP_200U);
int16_t setModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro);
int16_t setModulationParamsFSK(uint32_t br, uint8_t pulseShape, uint8_t rxBw, uint32_t freqDev);
int16_t setPacketParams(uint16_t preambleLength, uint8_t crcType, uint8_t payloadLength, uint8_t headerType, uint8_t invertIQ = RADIOLIB_SX126X_LORA_IQ_STANDARD);
int16_t setPacketParams(uint16_t preambleLength, uint8_t crcType, uint8_t payloadLength, uint8_t headerType, uint8_t invertIQ);
int16_t setPacketParamsFSK(uint16_t preambleLength, uint8_t crcType, uint8_t syncWordLength, uint8_t addrComp, uint8_t whitening, uint8_t packetType = RADIOLIB_SX126X_GFSK_PACKET_VARIABLE, uint8_t payloadLength = 0xFF, uint8_t preambleDetectorLength = RADIOLIB_SX126X_GFSK_PREAMBLE_DETECT_16);
int16_t setBufferBaseAddress(uint8_t txBaseAddress = 0x00, uint8_t rxBaseAddress = 0x00);
int16_t setRegulatorMode(uint8_t mode);
@ -1205,6 +1205,7 @@ class SX126x: public PhysicalLayer {
uint32_t _tcxoDelay = 0;
size_t _implicitLen = 0;
uint8_t _invertIQ = RADIOLIB_SX126X_LORA_IQ_STANDARD;
const char* _chipType;
// Allow subclasses to define different TX modes