Adapted sx1280-hal to new IRQ handler

This commit is contained in:
2024-06-22 22:17:52 -03:00
parent ffa8efac7b
commit 950bcc8b90
2 changed files with 17 additions and 13 deletions

View File

@@ -23,13 +23,7 @@ Maintainer: Miguel Luis, Gregory Cristian and Matthieu Verdy
* \brief Used to block execution waiting for low state on radio busy pin.
* Essentially used in SPI communications
*/
#define WaitOnBusy( ) for(uint8_t val=0; val != 1; BUSY->read(&val));
/*!
* \brief Macro used to enable and disable callback without disabling IRQ
*/
#define setDioIrqEnabled( enabled ) EXTIHandler::getInstance()->setCallbackEnabled(DIO1, enabled)
#define WaitOnBusy( ) for(uint8_t val=1; val; BUSY->read(&val));
// This code handles cases where assert_param is undefined
#ifndef assert_param
@@ -63,10 +57,7 @@ void SX1280Hal::IoIrqInit( DioIrqHandler irqHandler )
{
assert_param( RadioSpi != NULL );
SpiInit( );
std::function<void(void*)> callbackFunction = [this, irqHandler](void* ptr){(this->*irqHandler)();};
EXTIHandler::getInstance()->registerCallback(callbackFunction, nullptr, DIO1);
EXTIHandler::getInstance()->setCallbackEnabled(DIO1, true);
DIO1->registerExtiCallback(this);
}
void SX1280Hal::Reset( void )
@@ -264,3 +255,11 @@ uint8_t SX1280Hal::GetDioStatus( void )
retval += inter;
return retval;
}
void SX1280Hal::setDioIrqEnabled(bool enabled) {
dioIrqEnabled = enabled;
}
void SX1280Hal::irqHandler(InterruptReason *reason) {
}

View File

@@ -19,12 +19,11 @@ Maintainer: Miguel Luis and Gregory Cristian
#include "sx1280.h"
#include "../GPIO_Pin.hpp"
#include "../SPI_Peripheral.hpp"
#include "../EXTIHandler.hpp"
/*!
* \brief Actual implementation of a SX1280 radio
*/
class SX1280Hal : public SX1280
class SX1280Hal : public SX1280, private Interruptible
{
public:
/*!
@@ -157,6 +156,12 @@ protected:
* \param [in] irqHandler A function pointer of the function to be run on every DIO interrupt
*/
virtual void IoIrqInit( DioIrqHandler irqHandler );
private:
bool dioIrqEnabled = false;
void setDioIrqEnabled(bool enabled);
void irqHandler(InterruptReason* reason);
};
#endif // __SX1280_HAL_H__