1
0
mirror of https://github.com/sandeepmistry/arduino-LoRa.git synced 2025-07-28 12:01:58 +03:00

Added setGain for LNA Gain (#408)

* Added setGain for LNA Gain

Added setGain for LNA Gain

* Update API.md

Added API for setGain

* Added example to use setGain

Just use setGain after LoRa.begin
// set maximum LNA for better RX sensitivity
// 0: ADC is used and LNA gain is not used.
// 1-6: ADC is not used and LNA gain is used.
LoRa.setGain(6);

* Fixed spacing only

To change tabs to spaces.

* Delete LoRaReceiverCallbackWithLNAGain.ino

To remove as unnecessary.

* To add example for setGain

To add example for setGain as an optional setting.

* Added setGain

To add setGain

* Fixed typo for AGC

Fixed typo for AGC

* Fixed comment for LoRa.setGain(6)

* Make comment for setGain simpler

Make comment for setGain simpler
This commit is contained in:
IoTThinks.com
2020-11-11 08:51:26 +07:00
committed by GitHub
parent 21ec3d44bd
commit 090fe65108
5 changed files with 85 additions and 43 deletions

View File

@ -607,6 +607,32 @@ void LoRaClass::setOCP(uint8_t mA)
writeRegister(REG_OCP, 0x20 | (0x1F & ocpTrim));
}
void LoRaClass::setGain(uint8_t gain)
{
// check allowed range
if (gain > 6) {
gain = 6;
}
// set to standby
idle();
// set gain
if (gain == 0) {
// if gain = 0, enable AGC
writeRegister(REG_MODEM_CONFIG_3, 0x04);
} else {
// disable AGC
writeRegister(REG_MODEM_CONFIG_3, 0x00);
// clear Gain and set LNA boost
writeRegister(REG_LNA, 0x03);
// set gain
writeRegister(REG_LNA, readRegister(REG_LNA) | (gain << 5));
}
}
byte LoRaClass::random()
{
return readRegister(REG_RSSI_WIDEBAND);

View File

@ -77,6 +77,8 @@ public:
void disableInvertIQ();
void setOCP(uint8_t mA); // Over Current Protection control
void setGain(uint8_t gain); // Set LNA gain
// deprecated
void crc() { enableCrc(); }