[CC1101] Implemented RF switch control

This commit is contained in:
jgromes 2020-06-18 16:32:11 +02:00
parent 78022ce6ad
commit 3aafb2f5bf
2 changed files with 20 additions and 0 deletions

View file

@ -232,6 +232,9 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
// write packet to FIFO
SPIwriteRegisterBurst(CC1101_REG_FIFO, data, len);
// set RF switch (if present)
_mod->setRfSwitchState(true);
// set mode to transmit
SPIsendCommand(CC1101_CMD_TX);
@ -249,6 +252,9 @@ int16_t CC1101::startReceive() {
int state = SPIsetRegValue(CC1101_REG_IOCFG0, CC1101_GDOX_SYNC_WORD_SENT_OR_RECEIVED);
RADIOLIB_ASSERT(state);
// set RF switch (if present)
_mod->setRfSwitchState(false);
// set mode to receive
SPIsendCommand(CC1101_CMD_RX);
@ -710,6 +716,10 @@ int16_t CC1101::setEncoding(uint8_t encoding) {
}
}
void CC1101::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
_mod->setRfSwitchPins(rxEn, txEn);
}
int16_t CC1101::config() {
// Reset the radio. Registers may be dirty from previous usage.
SPIsendCommand(CC1101_CMD_RESET);

View file

@ -864,6 +864,16 @@ class CC1101: 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
private:
#endif