firmware/src/mesh/SX128xInterface.h

72 lines
2.0 KiB
C
Raw Normal View History

2022-10-16 17:07:58 +00:00
#pragma once
#include "RadioLibInterface.h"
/**
* \brief Adapter for SX128x radio family. Implements common logic for child classes.
2022-11-02 12:12:15 +00:00
* \tparam T RadioLib module type for SX128x: SX1280.
2022-10-16 17:07:58 +00:00
*/
2023-01-21 13:34:29 +00:00
template <class T> class SX128xInterface : public RadioLibInterface
2022-10-16 17:07:58 +00:00
{
public:
SX128xInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi);
/// Initialise the Driver transport hardware and software.
/// Make sure the Driver is properly configured before calling init().
/// \return true if initialisation succeeded.
virtual bool init() override;
virtual bool wideLora() override;
2022-10-16 17:07:58 +00:00
/// Apply any radio provisioning changes
/// Make sure the Driver is properly configured before calling init().
/// \return true if initialisation succeeded.
virtual bool reconfigure() override;
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
virtual bool sleep() override;
bool isIRQPending() override { return lora.getIrqStatus() != 0; }
2022-10-16 17:07:58 +00:00
protected:
2022-10-16 17:07:58 +00:00
/**
2023-01-21 13:34:29 +00:00
* Specific module instance
2022-10-16 17:07:58 +00:00
*/
T lora;
/**
* Glue functions called from ISR land
*/
virtual void disableInterrupt() override;
/**
* Enable a particular ISR callback glue function
*/
virtual void enableInterrupt(void (*callback)()) { lora.setDio1Action(callback); }
/** can we detect a LoRa preamble on the current channel? */
virtual bool isChannelActive() override;
/** are we actively receiving a packet (only called during receiving state) */
virtual bool isActivelyReceiving() override;
/**
* Start waiting to receive a message
*/
virtual void startReceive() override;
/**
* We override to turn on transmitter power as needed.
*/
virtual void configHardwareForSend() override;
/**
* Add SNR data to received messages
*/
virtual void addReceiveMetadata(MeshPacket *mp) override;
virtual void setStandby() override;
private:
};