Skip to content

Commit c8ddaff

Browse files
Merge pull request #46 from leommxj/dev
add code for enable or disable iqinverted register
2 parents 420edc6 + 7a1a5c4 commit c8ddaff

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/lora/API.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,18 @@ LoRa.enableCrc();
302302
LoRa.disableCrc();
303303
```
304304

305+
### iqInverted
306+
307+
Enable or disable iqInverted for TX/RX
308+
309+
```arduino
310+
LoRa.disableInvertIQ();
311+
LoRa.enableInvertIQ();
312+
LoRa.enableTxInvertIQ();
313+
LoRa.enableRxInvertIQ();
314+
315+
```
316+
305317
## Other functions
306318

307319
### Random

src/lora/LoRa.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@
4747
#define IRQ_PAYLOAD_CRC_ERROR_MASK 0x20
4848
#define IRQ_RX_DONE_MASK 0x40
4949

50+
/*!
51+
* RegInvertIQ
52+
*/
53+
#define RFLR_INVERTIQ_RX_MASK 0xBF
54+
#define RFLR_INVERTIQ_RX_OFF 0x00
55+
#define RFLR_INVERTIQ_RX_ON 0x40
56+
#define RFLR_INVERTIQ_TX_MASK 0xFE
57+
#define RFLR_INVERTIQ_TX_OFF 0x01
58+
#define RFLR_INVERTIQ_TX_ON 0x00
59+
60+
#define REG_LR_INVERTIQ 0x33
61+
62+
/*!
63+
* RegInvertIQ2
64+
*/
65+
#define RFLR_INVERTIQ2_ON 0x19
66+
#define RFLR_INVERTIQ2_OFF 0x1D
67+
68+
#define REG_LR_INVERTIQ2 0x3B
69+
5070

5171
#define MAX_PKT_LENGTH 255
5272

@@ -464,6 +484,30 @@ void LoRaClass::disableCrc()
464484
writeRegister(REG_MODEM_CONFIG_2, readRegister(REG_MODEM_CONFIG_2) & 0xfb);
465485
}
466486

487+
void LoRaClass::enableTxInvertIQ()
488+
{
489+
writeRegister( REG_LR_INVERTIQ, ( ( readRegister( REG_LR_INVERTIQ ) & RFLR_INVERTIQ_TX_MASK & RFLR_INVERTIQ_RX_MASK ) | RFLR_INVERTIQ_RX_OFF | RFLR_INVERTIQ_TX_ON ) );
490+
writeRegister( REG_LR_INVERTIQ2, RFLR_INVERTIQ2_ON );
491+
}
492+
493+
void LoRaClass::enableRxInvertIQ()
494+
{
495+
writeRegister( REG_LR_INVERTIQ, ( ( readRegister( REG_LR_INVERTIQ ) & RFLR_INVERTIQ_TX_MASK & RFLR_INVERTIQ_RX_MASK ) | RFLR_INVERTIQ_RX_ON | RFLR_INVERTIQ_TX_OFF ) );
496+
writeRegister( REG_LR_INVERTIQ2, RFLR_INVERTIQ2_ON );
497+
}
498+
499+
void LoRaClass::disableInvertIQ()
500+
{
501+
writeRegister( REG_LR_INVERTIQ, ( ( readRegister( REG_LR_INVERTIQ ) & RFLR_INVERTIQ_TX_MASK & RFLR_INVERTIQ_RX_MASK ) | RFLR_INVERTIQ_RX_OFF | RFLR_INVERTIQ_TX_OFF ) );
502+
writeRegister( REG_LR_INVERTIQ2, RFLR_INVERTIQ2_OFF );
503+
}
504+
505+
void LoRaClass::enableInvertIQ()
506+
{
507+
writeRegister( REG_LR_INVERTIQ, ( ( readRegister( REG_LR_INVERTIQ ) & RFLR_INVERTIQ_TX_MASK & RFLR_INVERTIQ_RX_MASK ) | RFLR_INVERTIQ_RX_ON | RFLR_INVERTIQ_TX_ON ) );
508+
writeRegister( REG_LR_INVERTIQ2, RFLR_INVERTIQ2_ON );
509+
}
510+
467511
byte LoRaClass::random()
468512
{
469513
return readRegister(REG_RSSI_WIDEBAND);

src/lora/LoRa.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ class LoRaClass : public Stream {
7777
void setSyncWord(int sw);
7878
void enableCrc();
7979
void disableCrc();
80+
void enableTxInvertIQ();
81+
void enableRxInvertIQ();
82+
void enableInvertIQ();
83+
void disableInvertIQ();
8084

8185
// deprecated
8286
void crc() { enableCrc(); }

0 commit comments

Comments
 (0)