From 9dde85598bf9e3ab8fbfa4549646c7fe4f2ffdae Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 8 Apr 2023 21:44:51 +0200 Subject: [PATCH] [SX126x] Added IQ inversion --- src/modules/SX126x/SX126x.cpp | 13 +++++++++++++ src/modules/SX126x/SX126x.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index e00bea5e..ab308961 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1419,6 +1419,19 @@ uint8_t SX126x::randomByte() { return(randByte); } +int16_t SX126x::invertIQ(bool invertIQ) { + if(getPacketType() != RADIOLIB_SX126X_PACKET_TYPE_LORA) { + return(RADIOLIB_ERR_WRONG_MODEM); + } + + uint8_t invert = RADIOLIB_SX126X_LORA_IQ_STANDARD; + if(invertIQ) { + invert = RADIOLIB_SX126X_LORA_IQ_INVERTED; + } + + return(setPacketParams(_preambleLength, _crcType, _implicitLen, _headerType, invert)); +} + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void SX126x::setDirectAction(void (*func)(void)) { setDio1Action(func); diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index a19c7248..51a5b4c6 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -1059,6 +1059,15 @@ class SX126x: public PhysicalLayer { */ uint8_t randomByte(); + /*! + \brief Enable/disable inversion of the I and Q signals + + \param invertIQ QI inversion enabled (true) or disabled (false); + + \returns \ref status_codes + */ + int16_t invertIQ(bool invertIQ); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Set interrupt service routine function to call when data bit is receveid in direct mode.