From 93981f1fcbae458ced7cc2e0f5859e6db00caf9d Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Wed, 26 Feb 2020 15:54:41 +0100 Subject: [PATCH] [nRF24] Added "isCarrierDetected()" --- src/modules/nRF24/nRF24.cpp | 4 ++++ src/modules/nRF24/nRF24.h | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 14f9a943..3bd01719 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -426,6 +426,10 @@ int16_t nRF24::getStatus(uint8_t mask) { return(_mod->SPIgetRegValue(NRF24_REG_STATUS) & mask); } +bool nRF24::isCarrierDetected() { + return(_mod->SPIgetRegValue(NRF24_REG_RPD, 0,0)) == 1; +} + int16_t nRF24::setFrequencyDeviation(float freqDev) { // nRF24 is unable to set frequency deviation // this method is implemented only for PhysicalLayer compatibility diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index 6eafc342..4528c949 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -392,6 +392,13 @@ class nRF24: public PhysicalLayer { */ int16_t getStatus(uint8_t mask = 0xFF); + /*! + \brief Checks if carrier was detected during last RX + + \returns Whatever the carrier was above threshold. + */ + bool isCarrierDetected(); + /*! \brief Dummy configuration method, to ensure PhysicalLayer compatibility.