modm API documentation
modm::Sx1276< SpiMaster, Cs > Struct Template Reference

#include <modm/driver/radio/sx1276.hpp>

Inheritance diagram for modm::Sx1276< SpiMaster, Cs >:
modm::SpiDevice< SpiMaster > modm::NestedResumable< 6 >

Public Typedefs

typedef modm::Configuration< OpModeRegister_t, ModemMode, Bit0|Bit1|Bit2 > ModemMode_t
 
typedef modm::Configuration< ModemConfig1_t, Bandwidth, Bit7|Bit6|Bit5|Bit4 > Bandwidth_t
 
typedef modm::Configuration< ModemConfig1_t, CodingRate, Bit3|Bit2|Bit1 > CodingRate_t
 
typedef modm::Configuration< ModemConfig2_t, SpreadingFactor, Bit7|Bit6|Bit5|Bit4 > SpreadingFactor_t
 

Public Types

enum  Sx1276Register : uint8_t
 Definitions of all the Registers of the modem in LoRa mode.
 
enum  OpModeRegister : uint8_t
 Operation mode register.
 
enum  ModemMode : uint8_t
 Modem operation modes.
 
enum  Interrupts : uint8_t
 Available interrupts with their positions in the flag and mask register.
 
enum  ModemConfig1 : uint8_t
 Operation mode register.
 
enum  Bandwidth : uint8_t
 LoRa Bandwidth Modes.
 
enum  CodingRate : uint8_t
 LoRa Coding Rate.
 
enum  ModemConfig2 : uint8_t
 
enum  ModemConfig3 : uint8_t
 
enum  SpreadingFactor : uint8_t
 Available Spreading Factors.
 

Public Member Functions

 Sx1276 ()
 Construct a new Sx1276 Driver.
 
modm::ResumableResult< void > initialize ()
 Initialize the modem into Lora mode.
 
modm::ResumableResult< void > setModemParams (Bandwidth bw, SpreadingFactor sf, CodingRate cr, bool implicitHeader, bool payloadCrc)
 Setup the modem parameters. More...
 
modm::ResumableResult< void > setCarrierFrequency (frequency_t freq)
 Set the carrier frequency of the Modem. More...
 
modm::ResumableResult< void > setSyncWord (uint8_t syncWord)
 Set the sync word for the LoRa packages. More...
 
modm::ResumableResult< bool > transmit (uint8_t *data, uint8_t length)
 Transmit a single package. More...
 
modm::ResumableResult< void > enableListening ()
 Enable the Rx mode and start listening for packages.
 
modm::ResumableResult< void > disableListening ()
 Disable Rx mode.
 
modm::ResumableResult< uint8_t > readPacket (uint8_t *data, uint8_t maxLength)
 Reads a package from the modem if one is available. The return value indicates how many bytes have been read from the last received package. If the return value is 0 no package has been received, is it larger than the max length parameter, the package was bigger than the buffer provided and got discarded. More...
 
modm::ResumableResult< int8_t > getPacketSnr ()
 Get the signal to noise ratio for the last received packet. More...
 
modm::ResumableResult< int16_t > getPacketRssi ()
 Get the recieved signal strength indicator (RSSI) of the last received packet. More...
 
modm::ResumableResult< int16_t > getCurrentRssi ()
 Get the current recieved signal strength indicator (RSSI) More...
 
 MODM_FLAGS8 (OpModeRegister)
 
 MODM_FLAGS8 (Interrupts)
 
 MODM_FLAGS8 (ModemConfig1)
 
 MODM_FLAGS8 (ModemConfig2)
 
 MODM_FLAGS8 (ModemConfig3)
 
void attachConfigurationHandler (Spi::ConfigurationHandler handler)
 

Static Public Attributes

static constexpr int16_t rssiOffsetLF = -164
 

Protected Member Functions

bool acquireMaster ()
 
bool releaseMaster ()
 
modm::ResumableResult< ReturnType > resumable function (...)
 
int8_t getResumableDepth () const
 
bool isResumableRunning () const
 
void stopResumable ()
 Force all resumable functions to stop running at the current nesting level.
 

Detailed Description

template<typename SpiMaster, typename Cs>
struct modm::Sx1276< SpiMaster, Cs >

Template Parameters
SpiMasterSpiMaster interface
CsChip-select pin
Author
Benjamin Carrick

Member Function Documentation

modm::ResumableResult< ReturnType > resumable modm::NestedResumable< 1 >::function (   ...)
inherited

Run the resumable function.

You need to implement this method in you subclass yourself.

Returns
>NestingError if still running, <=NestingError if it has finished.
template<typename SpiMaster , typename Cs >
modm::ResumableResult<int16_t> modm::Sx1276< SpiMaster, Cs >::getCurrentRssi ( )

Get the current recieved signal strength indicator (RSSI)

Returns
The RSSI value of the last received packet
template<typename SpiMaster , typename Cs >
modm::ResumableResult<int16_t> modm::Sx1276< SpiMaster, Cs >::getPacketRssi ( )

Get the recieved signal strength indicator (RSSI) of the last received packet.

Returns
The RSSI value of the last received packet
template<typename SpiMaster , typename Cs >
modm::ResumableResult<int8_t> modm::Sx1276< SpiMaster, Cs >::getPacketSnr ( )

Get the signal to noise ratio for the last received packet.

Returns
The raw signal to noise ratio in dB (has to be divided by 4 for the actual value)
int8_t modm::NestedResumable< 1 >::getResumableDepth ( ) const
inheritedinline
Returns
the nesting depth in the current resumable function, or -1 if called outside any resumable function
bool modm::NestedResumable< 1 >::isResumableRunning ( ) const
inheritedinline
Returns
true if a resumable function is running at the current nesting level, else false
template<typename SpiMaster , typename Cs >
modm::ResumableResult<uint8_t> modm::Sx1276< SpiMaster, Cs >::readPacket ( uint8_t *  data,
uint8_t  maxLength 
)

Reads a package from the modem if one is available. The return value indicates how many bytes have been read from the last received package. If the return value is 0 no package has been received, is it larger than the max length parameter, the package was bigger than the buffer provided and got discarded.

Parameters
dataA pointer to a buffer where received data will be stored
maxLengthThe maximum amount of bytes that can be read
Returns
The amount of bytes in the last package
template<typename SpiMaster , typename Cs >
modm::ResumableResult<void> modm::Sx1276< SpiMaster, Cs >::setCarrierFrequency ( frequency_t  freq)

Set the carrier frequency of the Modem.

Parameters
freqThe Carrier frequency the modem will be tuned to
template<typename SpiMaster , typename Cs >
modm::ResumableResult<void> modm::Sx1276< SpiMaster, Cs >::setModemParams ( Bandwidth  bw,
SpreadingFactor  sf,
CodingRate  cr,
bool  implicitHeader,
bool  payloadCrc 
)

Setup the modem parameters.

Parameters
bwThe Bandwidth of the LoRa Transmission
sfThe Spreading factor for each symbol
crThe Coding rate for the symbols
implicitHeaderRun the modem in implicit header mode
payloadCrcAppend CRC checksums to validate the packages
template<typename SpiMaster , typename Cs >
modm::ResumableResult<void> modm::Sx1276< SpiMaster, Cs >::setSyncWord ( uint8_t  syncWord)

Set the sync word for the LoRa packages.

Parameters
syncWordThe new sync word of upcoming lora packages
template<typename SpiMaster , typename Cs >
modm::ResumableResult<bool> modm::Sx1276< SpiMaster, Cs >::transmit ( uint8_t *  data,
uint8_t  length 
)

Transmit a single package.

Parameters
dataA pointer to the payload data of the Package
lengthThe length of the payload data in bytes
Returns
Returns true if transmission has started. False if the buffer was already sending

The documentation for this struct was generated from the following files: