From cb45f4fe5e81d4259594bb57251ebc8606e1154c Mon Sep 17 00:00:00 2001 From: SzczepanLeon <75840303+SzczepanLeon@users.noreply.github.com> Date: Sun, 3 Nov 2024 18:25:44 +0100 Subject: [PATCH] [SX127x/RF69] Added setFifoThreshold (#1309) * [SX127x] Added setFifoThreshold * [SX127x] Added setFifoThreshold * Add setFifoThreshold to RF69 class. * Documentation update, about setFifoThreshold. --- src/modules/RF69/RF69.cpp | 4 ++++ src/modules/RF69/RF69.h | 8 ++++++++ src/modules/SX127x/SX127x.cpp | 4 ++++ src/modules/SX127x/SX127x.h | 8 ++++++++ 4 files changed, 24 insertions(+) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 2bbfeb57..f87270be 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -321,6 +321,10 @@ void RF69::clearFifoEmptyAction() { clearDio1Action(); } +void RF69::setFifoThreshold(uint8_t threshold) { + this->mod->SPIsetRegValue(RADIOLIB_RF69_REG_FIFO_THRESH, threshold, 6, 0); +} + void RF69::setFifoFullAction(void (*func)(void)) { // set the interrupt this->mod->SPIsetRegValue(RADIOLIB_RF69_REG_FIFO_THRESH, RADIOLIB_RF69_FIFO_THRESH, 6, 0); diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index a7a25e49..a5691b93 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -648,6 +648,14 @@ class RF69: public PhysicalLayer { */ void clearFifoEmptyAction(); + /*! + \brief Set FIFO threshold level. + Be aware that threshold is also set in setFifoFullAction method. + setFifoThreshold method must be called AFTER calling setFifoFullAction! + \param Threshold level. + */ + void setFifoThreshold(uint8_t threshold); + /*! \brief Set interrupt service routine function to call when FIFO is full. \param func Pointer to interrupt service routine. diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index e4ba4c75..82755db0 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -504,6 +504,10 @@ void SX127x::clearFifoEmptyAction() { clearDio1Action(); } +void SX127x::setFifoThreshold(uint8_t threshold) { + this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_FIFO_THRESH, threshold, 5, 0); +} + void SX127x::setFifoFullAction(void (*func)(void)) { // set the interrupt this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_FIFO_THRESH, RADIOLIB_SX127X_FIFO_THRESH, 5, 0); diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index c54a549f..af00e575 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -761,6 +761,14 @@ class SX127x: public PhysicalLayer { */ void clearFifoEmptyAction(); + /*! + \brief Set FIFO threshold level. + Be aware that threshold is also set in setFifoFullAction method. + setFifoThreshold method must be called AFTER calling setFifoFullAction! + \param Threshold level. + */ + void setFifoThreshold(uint8_t threshold); + /*! \brief Set interrupt service routine function to call when FIFO is full. \param func Pointer to interrupt service routine.