Skip to content

Commit 7c2ebfd

Browse files
Force LDO option set or unset (sandeepmistry#668)
* Force LDO option set or unset Some remote clients needs LDO using on any Spreading Factor. CDEbyte E32 for example. * LDO state setter function realized * Update keywords, minor style tweaks --------- Co-authored-by: Sandeep Mistry <[email protected]>
1 parent 71d4c29 commit 7c2ebfd

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

keywords.txt

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ enableCrc KEYWORD2
5151
disableCrc KEYWORD2
5252
enableInvertIQ KEYWORD2
5353
disableInvertIQ KEYWORD2
54+
enableLowDataRateOptimize KEYWORD2
55+
disableLowDataRateOptimize KEYWORD2
5456
setGain KEYWORD2
5557

5658
random KEYWORD2

src/LoRa.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,13 @@ void LoRaClass::setLdoFlag()
586586
writeRegister(REG_MODEM_CONFIG_3, config3);
587587
}
588588

589+
void LoRaClass::setLdoFlagForced(const boolean ldoOn)
590+
{
591+
uint8_t config3 = readRegister(REG_MODEM_CONFIG_3);
592+
bitWrite(config3, 3, ldoOn);
593+
writeRegister(REG_MODEM_CONFIG_3, config3);
594+
}
595+
589596
void LoRaClass::setCodingRate4(int denominator)
590597
{
591598
if (denominator < 5) {
@@ -632,6 +639,16 @@ void LoRaClass::disableInvertIQ()
632639
writeRegister(REG_INVERTIQ2, 0x1d);
633640
}
634641

642+
void LoRaClass::enableLowDataRateOptimize()
643+
{
644+
setLdoFlagForced(true);
645+
}
646+
647+
void LoRaClass::disableLowDataRateOptimize()
648+
{
649+
setLdoFlagForced(false);
650+
}
651+
635652
void LoRaClass::setOCP(uint8_t mA)
636653
{
637654
uint8_t ocpTrim = 27;

src/LoRa.h

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class LoRaClass : public Stream {
7979
void disableCrc();
8080
void enableInvertIQ();
8181
void disableInvertIQ();
82+
void enableLowDataRateOptimize();
83+
void disableLowDataRateOptimize();
8284

8385
void setOCP(uint8_t mA); // Over Current Protection control
8486

@@ -107,6 +109,7 @@ class LoRaClass : public Stream {
107109
long getSignalBandwidth();
108110

109111
void setLdoFlag();
112+
void setLdoFlagForced(const boolean);
110113

111114
uint8_t readRegister(uint8_t address);
112115
void writeRegister(uint8_t address, uint8_t value);

0 commit comments

Comments
 (0)