RF switch control base
pull/163/head
jgromes 2020-06-18 16:31:38 +02:00
rodzic cec0c4d1e2
commit 78022ce6ad
3 zmienionych plików z 45 dodań i 0 usunięć

Wyświetl plik

@ -127,6 +127,7 @@ setEncoding KEYWORD2
getIRQFlags KEYWORD2
getModemStatus KEYWORD2
getTempRaw KEYWORD2
setRfSwitchPins KEYWORD2
# RF69-specific
setAESKey KEYWORD2

Wyświetl plik

@ -314,3 +314,27 @@ void Module::noTone(RADIOLIB_PIN_TYPE pin) {
}
#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);
}
}

Wyświetl plik

@ -386,6 +386,23 @@ class Module {
*/
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
private:
#endif
@ -399,6 +416,9 @@ class Module {
SPIClass* _spi;
SPISettings _spiSettings;
bool _useRfSwitch = false;
RADIOLIB_PIN_TYPE _rxEn, _txEn;
uint32_t _ATtimeout = 15000;
};