Added RADIOLIB_EXCLUDE_DIRECT_RECEIVE exclusion macro (#557)

This commit is contained in:
jgromes 2022-08-15 19:19:59 +02:00
parent ec94177c2a
commit da0993a6ed
17 changed files with 49 additions and 7 deletions

View file

@ -108,6 +108,7 @@
//#define RADIOLIB_EXCLUDE_MORSE
//#define RADIOLIB_EXCLUDE_RTTY
//#define RADIOLIB_EXCLUDE_SSTV
//#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE
#else
#if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR))

View file

@ -890,6 +890,7 @@ int16_t CC1101::getChipVersion() {
return(SPIgetRegValue(RADIOLIB_CC1101_REG_VERSION));
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
void CC1101::setDirectAction(void (*func)(void)) {
setGdo0Action(func);
}
@ -897,6 +898,7 @@ void CC1101::setDirectAction(void (*func)(void)) {
void CC1101::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
}
#endif
int16_t CC1101::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) {
if (pin > 2)

View file

@ -920,6 +920,7 @@ class CC1101: public PhysicalLayer {
*/
int16_t getChipVersion();
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
/*!
\brief Set interrupt service routine function to call when data bit is receveid in direct mode.
@ -933,6 +934,7 @@ class CC1101: public PhysicalLayer {
\param pin Pin on which to read.
*/
void readBit(RADIOLIB_PIN_TYPE pin);
#endif
/*!
\brief Configure DIO pin mapping to get a given signal on a DIO pin (if available).

View file

@ -895,6 +895,7 @@ uint8_t RF69::randomByte() {
return(randByte);
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
void RF69::setDirectAction(void (*func)(void)) {
setDio1Action(func);
}
@ -902,15 +903,18 @@ void RF69::setDirectAction(void (*func)(void)) {
void RF69::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
}
#endif
int16_t RF69::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) {
if (pin > 5)
return RADIOLIB_ERR_INVALID_DIO_PIN;
if(pin > 5) {
return(RADIOLIB_ERR_INVALID_DIO_PIN);
}
if (pin < 4)
if(pin < 4) {
return(_mod->SPIsetRegValue(RADIOLIB_RF69_REG_DIO_MAPPING_1, value, 7 - 2 * pin, 6 - 2 * pin));
else
return(_mod->SPIsetRegValue(RADIOLIB_RF69_REG_DIO_MAPPING_2, value, 15 - 2 * pin, 14 - 2 * pin));
}
return(_mod->SPIsetRegValue(RADIOLIB_RF69_REG_DIO_MAPPING_2, value, 15 - 2 * pin, 14 - 2 * pin));
}
int16_t RF69::getChipVersion() {

View file

@ -985,6 +985,7 @@ class RF69: public PhysicalLayer {
*/
int16_t getChipVersion();
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
/*!
\brief Set interrupt service routine function to call when data bit is receveid in direct mode.
@ -998,6 +999,7 @@ class RF69: public PhysicalLayer {
\param pin Pin on which to read.
*/
void readBit(RADIOLIB_PIN_TYPE pin);
#endif
/*!
\brief Configure DIO pin mapping to get a given signal on a DIO pin (if available).

View file

@ -1233,6 +1233,7 @@ uint8_t SX126x::randomByte() {
return(randByte);
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
void SX126x::setDirectAction(void (*func)(void)) {
// SX126x is unable to perform direct mode reception
// this method is implemented only for PhysicalLayer compatibility
@ -1244,6 +1245,7 @@ void SX126x::readBit(RADIOLIB_PIN_TYPE pin) {
// this method is implemented only for PhysicalLayer compatibility
(void)pin;
}
#endif
int16_t SX126x::setTCXO(float voltage, uint32_t delay) {
// set mode to standby

View file

@ -928,6 +928,7 @@ class SX126x: public PhysicalLayer {
*/
uint8_t randomByte();
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
/*!
\brief Dummy method, to ensure PhysicalLayer compatibility.
@ -941,6 +942,8 @@ class SX126x: public PhysicalLayer {
\param pin Ignored.
*/
void readBit(RADIOLIB_PIN_TYPE pin);
#endif
#if !defined(RADIOLIB_GODMODE)
protected:

View file

@ -1493,6 +1493,7 @@ int16_t SX127x::invertIQ(bool invertIQ) {
return(state);
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
void SX127x::setDirectAction(void (*func)(void)) {
setDio1Action(func);
}
@ -1500,6 +1501,7 @@ void SX127x::setDirectAction(void (*func)(void)) {
void SX127x::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
}
#endif
int16_t SX127x::setFHSSHoppingPeriod(uint8_t freqHoppingPeriod) {
return(_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD, freqHoppingPeriod));

View file

@ -557,8 +557,8 @@
#define RADIOLIB_SX127X_DIO5_PACK_PLL_LOCK 0b00010000 // 5 4
#define RADIOLIB_SX127X_DIO5_PACK_DATA 0b00100000 // 5 4
#define RADIOLIB_SX127X_DIO5_PACK_MODE_READY 0b00110000 // 5 4
#define RADIOLIB_SX127X_DIO_MAP_PREAMBLE_DETECT 0b00000001 // 0 0
#define RADIOLIB_SX127X_DIO_MAP_RSSI 0b00000000 // 0 0
#define RADIOLIB_SX127X_DIO_MAP_PREAMBLE_DETECT 0b00000001 // 0 0
#define RADIOLIB_SX127X_DIO_MAP_RSSI 0b00000000 // 0 0
// SX1272_REG_PLL_HOP + SX1278_REG_PLL_HOP
#define RADIOLIB_SX127X_FAST_HOP_OFF 0b00000000 // 7 7 carrier frequency validated when FRF registers are written
@ -1163,6 +1163,7 @@ class SX127x: public PhysicalLayer {
*/
int16_t invertIQ(bool invertIQ);
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
/*!
\brief Set interrupt service routine function to call when data bit is receveid in direct mode.
@ -1176,6 +1177,7 @@ class SX127x: public PhysicalLayer {
\param pin Pin on which to read.
*/
void readBit(RADIOLIB_PIN_TYPE pin);
#endif
/*!
\brief Sets the hopping period and enables FHSS

View file

@ -1243,6 +1243,7 @@ uint8_t SX128x::randomByte() {
return(0);
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
void SX128x::setDirectAction(void (*func)(void)) {
// SX128x is unable to perform direct mode reception
// this method is implemented only for PhysicalLayer compatibility
@ -1254,6 +1255,7 @@ void SX128x::readBit(RADIOLIB_PIN_TYPE pin) {
// this method is implemented only for PhysicalLayer compatibility
(void)pin;
}
#endif
uint8_t SX128x::getStatus() {
uint8_t data = 0;

View file

@ -812,6 +812,7 @@ class SX128x: public PhysicalLayer {
*/
uint8_t randomByte();
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
/*!
\brief Dummy method, to ensure PhysicalLayer compatibility.
@ -825,6 +826,7 @@ class SX128x: public PhysicalLayer {
\param pin Ignored.
*/
void readBit(RADIOLIB_PIN_TYPE pin);
#endif
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
protected:

View file

@ -589,6 +589,7 @@ int16_t Si443x::getChipVersion() {
return(_mod->SPIgetRegValue(RADIOLIB_SI443X_REG_DEVICE_VERSION));
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
void Si443x::setDirectAction(void (*func)(void)) {
setIrqAction(func);
}
@ -596,6 +597,7 @@ void Si443x::setDirectAction(void (*func)(void)) {
void Si443x::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
}
#endif
int16_t Si443x::fixedPacketLengthMode(uint8_t len) {
return(Si443x::setPacketMode(RADIOLIB_SI443X_FIXED_PACKET_LENGTH_ON, len));

View file

@ -802,6 +802,7 @@ class Si443x: public PhysicalLayer {
*/
int16_t getChipVersion();
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
/*!
\brief Set interrupt service routine function to call when data bit is receveid in direct mode.
@ -815,6 +816,7 @@ class Si443x: public PhysicalLayer {
\param pin Pin on which to read.
*/
void readBit(RADIOLIB_PIN_TYPE pin);
#endif
/*!
\brief Set modem in fixed packet length mode.

View file

@ -516,6 +516,7 @@ uint8_t nRF24::randomByte() {
return(0);
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
void nRF24::setDirectAction(void (*func)(void)) {
// nRF24 is unable to perform direct mode actions
// this method is implemented only for PhysicalLayer compatibility
@ -527,6 +528,7 @@ void nRF24::readBit(RADIOLIB_PIN_TYPE pin) {
// this method is implemented only for PhysicalLayer compatibility
(void)pin;
}
#endif
void nRF24::clearIRQ() {
// clear status bits

View file

@ -473,6 +473,7 @@ class nRF24: public PhysicalLayer {
*/
uint8_t randomByte();
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
/*!
\brief Dummy method, to ensure PhysicalLayer compatibility.
@ -486,6 +487,7 @@ class nRF24: public PhysicalLayer {
\param pin Ignored.
*/
void readBit(RADIOLIB_PIN_TYPE pin);
#endif
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
protected:

View file

@ -3,8 +3,10 @@
PhysicalLayer::PhysicalLayer(float freqStep, size_t maxPacketLength) {
_freqStep = freqStep;
_maxPacketLength = maxPacketLength;
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
_bufferBitPos = 0;
_bufferWritePos = 0;
#endif
}
int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) {
@ -188,6 +190,7 @@ int16_t PhysicalLayer::startDirect() {
return(state);
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
int16_t PhysicalLayer::available() {
return(_bufferWritePos);
}
@ -246,6 +249,7 @@ void PhysicalLayer::updateDirectBuffer(uint8_t bit) {
}
}
}
#endif
int16_t PhysicalLayer::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) {
return(RADIOLIB_ERR_UNSUPPORTED);

View file

@ -261,6 +261,7 @@ class PhysicalLayer {
*/
int16_t startDirect();
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
/*!
\brief Set sync word to be used to determine start of packet in direct reception mode.
@ -299,6 +300,7 @@ class PhysicalLayer {
\returns Byte from direct mode buffer.
*/
uint8_t read();
#endif
/*!
\brief Configure DIO pin mapping to get a given signal on a DIO pin (if available).
@ -311,8 +313,10 @@ class PhysicalLayer {
*/
virtual int16_t setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value);
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
protected:
void updateDirectBuffer(uint8_t bit);
#endif
#if !defined(RADIOLIB_GODMODE)
private:
@ -320,6 +324,7 @@ class PhysicalLayer {
float _freqStep;
size_t _maxPacketLength;
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
uint8_t _bufferBitPos;
uint8_t _bufferWritePos;
uint8_t _bufferReadPos;
@ -329,6 +334,7 @@ class PhysicalLayer {
uint8_t _directSyncWordLen;
uint32_t _directSyncWordMask;
bool _gotSync;
#endif
virtual Module* getMod() = 0;