mirror of
https://github.com/sandeepmistry/arduino-LoRa.git
synced 2025-04-19 13:02:14 +03:00
Add option to specify PA output pin in Lora.setTxPower(...) (#2)
This commit is contained in:
parent
ee09672759
commit
9c9914a2c4
7
API.md
7
API.md
@ -216,10 +216,15 @@ Change the TX power of the radio.
|
|||||||
|
|
||||||
```arduino
|
```arduino
|
||||||
LoRa.setTxPower(txPower);
|
LoRa.setTxPower(txPower);
|
||||||
|
|
||||||
|
LoRa.setTxPower(txPower, outputPin);
|
||||||
```
|
```
|
||||||
* `txPower` - TX power in dB, defaults to `17`
|
* `txPower` - TX power in dB, defaults to `17`
|
||||||
|
* `outputPin` - (optional) PA output pin, supported values are `PA_OUTPUT_RFO_PIN` and `PA_OUTPUT_PA_BOOST_PIN`, defaults to `PA_OUTPUT_PA_BOOST_PIN`.
|
||||||
|
|
||||||
Supported values are between `2` and `17`.
|
Supported values are between `2` and `17` for `PA_OUTPUT_PA_BOOST_PIN`, `0` and `14` for `PA_OUTPUT_RFO_PIN`.
|
||||||
|
|
||||||
|
Most modules have the PA output pin connected to PA BOOST,
|
||||||
|
|
||||||
### Frequency
|
### Frequency
|
||||||
|
|
||||||
|
@ -52,3 +52,6 @@ dumpRegisters KEYWORD2
|
|||||||
#######################################
|
#######################################
|
||||||
# Constants (LITERAL1)
|
# Constants (LITERAL1)
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
PA_OUTPUT_RFO_PIN LITERAL1
|
||||||
|
PA_OUTPUT_PA_BOOST_PIN LITERAL1
|
||||||
|
14
src/LoRa.cpp
14
src/LoRa.cpp
@ -297,8 +297,19 @@ void LoRaClass::sleep()
|
|||||||
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_SLEEP);
|
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_SLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRaClass::setTxPower(int level)
|
void LoRaClass::setTxPower(int level, int outputPin)
|
||||||
{
|
{
|
||||||
|
if (PA_OUTPUT_RFO_PIN == outputPin) {
|
||||||
|
// RFO
|
||||||
|
if (level < 0) {
|
||||||
|
level = 0;
|
||||||
|
} else if (level > 14) {
|
||||||
|
level = 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
writeRegister(REG_PA_CONFIG, 0x70 | level);
|
||||||
|
} else {
|
||||||
|
// PA BOOST
|
||||||
if (level < 2) {
|
if (level < 2) {
|
||||||
level = 2;
|
level = 2;
|
||||||
} else if (level > 17) {
|
} else if (level > 17) {
|
||||||
@ -307,6 +318,7 @@ void LoRaClass::setTxPower(int level)
|
|||||||
|
|
||||||
writeRegister(REG_PA_CONFIG, PA_BOOST | (level - 2));
|
writeRegister(REG_PA_CONFIG, PA_BOOST | (level - 2));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LoRaClass::setFrequency(long frequency)
|
void LoRaClass::setFrequency(long frequency)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
#define LORA_DEFAULT_RESET_PIN 9
|
#define LORA_DEFAULT_RESET_PIN 9
|
||||||
#define LORA_DEFAULT_DIO0_PIN 2
|
#define LORA_DEFAULT_DIO0_PIN 2
|
||||||
|
|
||||||
|
#define PA_OUTPUT_RFO_PIN 0
|
||||||
|
#define PA_OUTPUT_PA_BOOST_PIN 1
|
||||||
|
|
||||||
class LoRaClass : public Stream {
|
class LoRaClass : public Stream {
|
||||||
public:
|
public:
|
||||||
LoRaClass();
|
LoRaClass();
|
||||||
@ -38,7 +41,7 @@ public:
|
|||||||
void idle();
|
void idle();
|
||||||
void sleep();
|
void sleep();
|
||||||
|
|
||||||
void setTxPower(int level);
|
void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN);
|
||||||
void setFrequency(long frequency);
|
void setFrequency(long frequency);
|
||||||
void setSpreadingFactor(int sf);
|
void setSpreadingFactor(int sf);
|
||||||
void setSignalBandwidth(long sbw);
|
void setSignalBandwidth(long sbw);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user