Added external
RF switch control base
This commit is contained in:
parent
cec0c4d1e2
commit
78022ce6ad
3 changed files with 45 additions and 0 deletions
|
@ -127,6 +127,7 @@ setEncoding KEYWORD2
|
||||||
getIRQFlags KEYWORD2
|
getIRQFlags KEYWORD2
|
||||||
getModemStatus KEYWORD2
|
getModemStatus KEYWORD2
|
||||||
getTempRaw KEYWORD2
|
getTempRaw KEYWORD2
|
||||||
|
setRfSwitchPins KEYWORD2
|
||||||
|
|
||||||
# RF69-specific
|
# RF69-specific
|
||||||
setAESKey KEYWORD2
|
setAESKey KEYWORD2
|
||||||
|
|
|
@ -314,3 +314,27 @@ void Module::noTone(RADIOLIB_PIN_TYPE pin) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
||||||
|
_useRfSwitch = true;
|
||||||
|
_rxEn = rxEn;
|
||||||
|
_txEn = txEn;
|
||||||
|
Module::pinMode(rxEn, OUTPUT);
|
||||||
|
Module::pinMode(txEn, OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setRfSwitchState(bool tx) {
|
||||||
|
// check RF switch control is enabled
|
||||||
|
if(!_useRfSwitch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set pins
|
||||||
|
if(tx) {
|
||||||
|
Module::digitalWrite(_rxEn, LOW);
|
||||||
|
Module::digitalWrite(_txEn, HIGH);
|
||||||
|
} else {
|
||||||
|
Module::digitalWrite(_rxEn, HIGH);
|
||||||
|
Module::digitalWrite(_txEn, LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
20
src/Module.h
20
src/Module.h
|
@ -386,6 +386,23 @@ class Module {
|
||||||
*/
|
*/
|
||||||
static void noTone(RADIOLIB_PIN_TYPE pin);
|
static void noTone(RADIOLIB_PIN_TYPE pin);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\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);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Set RF switch state.
|
||||||
|
|
||||||
|
\param tx True to set RF switch to Tx, false to set switch to Rx.
|
||||||
|
*/
|
||||||
|
void setRfSwitchState(bool tx);
|
||||||
|
|
||||||
#ifndef RADIOLIB_GODMODE
|
#ifndef RADIOLIB_GODMODE
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
|
@ -399,6 +416,9 @@ class Module {
|
||||||
SPIClass* _spi;
|
SPIClass* _spi;
|
||||||
SPISettings _spiSettings;
|
SPISettings _spiSettings;
|
||||||
|
|
||||||
|
bool _useRfSwitch = false;
|
||||||
|
RADIOLIB_PIN_TYPE _rxEn, _txEn;
|
||||||
|
|
||||||
uint32_t _ATtimeout = 15000;
|
uint32_t _ATtimeout = 15000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue