[SX127x] Implemented RF switch control
This commit is contained in:
parent
5a3d7a7173
commit
4ad82f1572
3 changed files with 33 additions and 0 deletions
|
@ -49,6 +49,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() {
|
||||
|
|
|
@ -368,6 +368,9 @@ int16_t SX127x::startReceive(uint8_t len, uint8_t mode) {
|
|||
}
|
||||
}
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(false);
|
||||
|
||||
// set mode to receive
|
||||
return(setMode(mode));
|
||||
}
|
||||
|
@ -421,6 +424,9 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
// write packet to FIFO
|
||||
_mod->SPIwriteRegisterBurst(SX127X_REG_FIFO, data, len);
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(true);
|
||||
|
||||
// start transmission
|
||||
state |= setMode(SX127X_TX);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
@ -451,6 +457,9 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
// write packet to FIFO
|
||||
_mod->SPIwriteRegisterBurst(SX127X_REG_FIFO, data, len);
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(true);
|
||||
|
||||
// start transmission
|
||||
state |= setMode(SX127X_TX);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
@ -934,6 +943,10 @@ uint8_t SX127x::getModemStatus() {
|
|||
return(_mod->SPIreadRegister(SX127X_REG_MODEM_STAT));
|
||||
}
|
||||
|
||||
void SX127x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
||||
_mod->setRfSwitchPins(rxEn, txEn);
|
||||
}
|
||||
|
||||
int8_t SX127x::getTempRaw() {
|
||||
int8_t temp = 0;
|
||||
uint8_t previousOpMode;
|
||||
|
|
|
@ -921,6 +921,16 @@ class SX127x: public PhysicalLayer {
|
|||
*/
|
||||
int8_t getTempRaw();
|
||||
|
||||
/*!
|
||||
\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);
|
||||
|
||||
#ifdef RADIOLIB_DEBUG
|
||||
void regDump();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue