firmware/src/mesh/LR11x0Interface.h
Thomas Göttgens b43c7c0f23
LR1110 support (#3013)
* DOES NOT WORK

* trunk

* DOES NOT WORK

* trunk

* DOES NOT WORK

* trunk

* WIP: LR11x0 non functional interface code. Please don't expect a working firmware out of this! I don't know what i am doing! :-)

* trunk fmt

* use canon toolchain

* update and fix radiolib dependency

* Switch Radiolib back to GIT checkout

* enable tcxo and fix startReceive

* progress

* Correct midjudgement on scope of build defines.

* - enable peripheral power rail during startup init
- fix portduino builds

* add tracker pinout variant

* update to radiolib 6.6.0 API (aka: godmode is not for mere mortals)

* tracker is not so 'extra' any more

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2024-06-03 16:04:40 -05:00

72 lines
2.1 KiB
C++

#pragma once
#include "RadioLibInterface.h"
/**
* \brief Adapter for LR11x0 radio family. Implements common logic for child classes.
* \tparam T RadioLib module type for LR11x0: SX1262, SX1268.
*/
template <class T> class LR11x0Interface : public RadioLibInterface
{
public:
LR11x0Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst,
RADIOLIB_PIN_TYPE busy);
/// 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;
/// 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; }
protected:
/**
* Specific module instance
*/
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.setIrqAction(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(meshtastic_MeshPacket *mp) override;
virtual void setStandby() override;
private:
uint32_t activeReceiveStart = 0;
};