From 9d3a2bb72f0d0689a6d4049716a35367dea11667 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 8 Apr 2023 21:45:15 +0200 Subject: [PATCH] [SX128x] Added IQ inversion (#724) --- src/modules/SX128x/SX128x.cpp | 13 +++++++++++++ src/modules/SX128x/SX128x.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 3456e7c3..5a2619c8 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1283,6 +1283,19 @@ uint8_t SX128x::randomByte() { return(0); } +int16_t SX128x::invertIQ(bool invertIQ) { + if(getPacketType() != RADIOLIB_SX128X_PACKET_TYPE_LORA) { + return(RADIOLIB_ERR_WRONG_MODEM); + } + + uint8_t invert = RADIOLIB_SX128X_LORA_IQ_STANDARD; + if(invertIQ) { + invert = RADIOLIB_SX128X_LORA_IQ_INVERTED; + } + + return(setPacketParamsLoRa(_preambleLengthLoRa, _headerType, _payloadLen, _crcLoRa, invert)); +} + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void SX128x::setDirectAction(void (*func)(void)) { // SX128x is unable to perform direct mode reception diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index a3600f32..1aac8c74 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -829,6 +829,15 @@ class SX128x: 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 Dummy method, to ensure PhysicalLayer compatibility.