firmware/src/mesh/SX126xInterface.h

71 lines
1.9 KiB
C
Raw Normal View History

#pragma once
#include "RadioLibInterface.h"
/**
* \brief Adapter for SX126x radio family. Implements common logic for child classes.
* \tparam T RadioLib module type for SX126x: SX1262, SX1268.
*/
template<class T>
class SX126xInterface : public RadioLibInterface
{
public:
SX126xInterface(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.
2022-01-24 17:24:40 +00:00
virtual bool init() override;
/// Apply any radio provisioning changes
/// Make sure the Driver is properly configured before calling init().
/// \return true if initialisation succeeded.
2022-01-24 17:24:40 +00:00
virtual bool reconfigure() override;
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
2022-01-24 17:24:40 +00:00
virtual bool sleep() override;
2022-01-24 17:24:40 +00:00
bool isIRQPending() override { return lora.getIrqStatus() != 0; }
protected:
float currentLimit = 140; // Higher OCP limit for SX126x PA
/**
* Specific module instance
*/
T lora;
/**
* Glue functions called from ISR land
*/
2022-01-24 17:24:40 +00:00
virtual void disableInterrupt() override;
/**
* Enable a particular ISR callback glue function
*/
virtual void enableInterrupt(void (*callback)()) { lora.setDio1Action(callback); }
/** are we actively receiving a packet (only called during receiving state) */
2022-01-24 17:24:40 +00:00
virtual bool isActivelyReceiving() override;
/**
* Start waiting to receive a message
*/
2022-01-24 17:24:40 +00:00
virtual void startReceive() override;
/**
* We override to turn on transmitter power as needed.
*/
2022-01-24 17:24:40 +00:00
virtual void configHardwareForSend() override;
/**
* Add SNR data to received messages
*/
2022-01-24 17:24:40 +00:00
virtual void addReceiveMetadata(MeshPacket *mp) override;
2022-01-24 17:24:40 +00:00
virtual void setStandby() override;
private:
2022-01-24 17:24:40 +00:00
};