[SX126x] Implemented RF switch control (#153)
This commit is contained in:
parent
4ad82f1572
commit
d710a85985
3 changed files with 30 additions and 0 deletions
|
@ -51,6 +51,16 @@ void setup() {
|
|||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// some modules have an external RF switch
|
||||
// controlled via two pins (RX enable, TX enable)
|
||||
// to enable automatic control of the switch,
|
||||
// call the following method
|
||||
// RX enable: 4
|
||||
// TX enable: 5
|
||||
/*
|
||||
lora.setRfSwitchPins(4, 5);
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
|
@ -435,6 +435,9 @@ int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
state = fixSensitivity();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(true);
|
||||
|
||||
// start transmission
|
||||
state = setTx(SX126X_TX_TIMEOUT_NONE);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
@ -451,6 +454,9 @@ int16_t SX126x::startReceive(uint32_t timeout) {
|
|||
int16_t state = startReceiveCommon();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(true);
|
||||
|
||||
// set mode to receive
|
||||
state = setRx(timeout);
|
||||
|
||||
|
@ -1117,6 +1123,10 @@ int16_t SX126x::setEncoding(uint8_t encoding) {
|
|||
return(setWhitening(encoding));
|
||||
}
|
||||
|
||||
void SX126x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
||||
_mod->setRfSwitchPins(rxEn, txEn);
|
||||
}
|
||||
|
||||
int16_t SX126x::setTCXO(float voltage, uint32_t delay) {
|
||||
// set mode to standby
|
||||
standby();
|
||||
|
|
|
@ -843,6 +843,16 @@ class SX126x: public PhysicalLayer {
|
|||
*/
|
||||
int16_t setEncoding(uint8_t encoding);
|
||||
|
||||
/*!
|
||||
\brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state.
|
||||
When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch!
|
||||
|
||||
\param rxEn RX enable pin.
|
||||
|
||||
\param txEn TX enable pin.
|
||||
*/
|
||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
protected:
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue