modm API documentation
modm::Sx128x< Transport, Reset, Busy > Struct Template Reference

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

Inheritance diagram for modm::Sx128x< Transport, Reset, Busy >:
modm::Sx128xTransport::Command

Classes

struct  Ble
 
struct  Flrc
 
struct  Gfsk
 
struct  LoRa
 
union  ModulationParams
 
union  PacketParams
 
union  PacketStatus
 
struct  Ranging
 
struct  RxBufferStatus
 
struct  Status
 

Public Types

enum  Opcode : uint8_t
 
enum  Register : uint16_t
 
enum  SleepConfig : uint8_t
 
enum  StandbyConfig : uint8_t
 
enum  PeriodBase : uint8_t
 
enum  PacketType : uint8_t
 
enum  RampTime : uint8_t
 
enum  CadSymbolNumber : uint8_t
 
enum  RegulatorMode : uint8_t
 
enum  Irq : uint16_t
 
enum  UartDividerRatio : uint16_t
 
enum  RangingRole : uint8_t
 

Public Member Functions

bool isBusy ()
 Determine if radio is busy.
 
modm::ResumableResult< void > reset ()
 
modm::ResumableResult< bool > getStatus (Status *status)
 
modm::ResumableResult< bool > writeRegister (Register reg, uint8_t data)
 Writes a single byte in a data memory space at the specified address.
 
modm::ResumableResult< bool > writeRegister (Register reg, std::span< const uint8_t > data)
 Writes a block of bytes in a data memory space starting at a specific address.
 
modm::ResumableResult< bool > readRegister (Register reg, uint8_t *data)
 Read a single byte of data at the given address.
 
modm::ResumableResult< bool > readRegister (Register reg, std::span< uint8_t > data)
 Read a block of data starting at a given address.
 
modm::ResumableResult< bool > writeBuffer (uint8_t offset, std::span< const uint8_t > data)
 
modm::ResumableResult< bool > readBuffer (uint8_t offset, std::span< uint8_t > data)
 This function is used to read the received data payload.
 
modm::ResumableResult< bool > setSleep (SleepConfig_t sleepConfig)
 
modm::ResumableResult< bool > setStandby (StandbyConfig standbyConfig=StandbyConfig::StdbyRc)
 
modm::ResumableResult< bool > setFs ()
 
modm::ResumableResult< bool > setTx (PeriodBase periodBase, uint16_t periodBaseCount)
 
modm::ResumableResult< bool > setRx (PeriodBase periodBase, uint16_t periodBaseCount)
 
modm::ResumableResult< bool > setRxDutyCycle (PeriodBase periodBase, uint16_t rxPeriodBaseCount, uint16_t sleepPeriodBaseCount)
 
modm::ResumableResult< bool > setCad ()
 
modm::ResumableResult< bool > setTxContinuousWave ()
 
modm::ResumableResult< bool > setTxContinuousPreamble ()
 
modm::ResumableResult< bool > setPacketType (PacketType packetType)
 
modm::ResumableResult< bool > getPacketType (PacketType *packetType)
 Get the current operating packet type of the radio.
 
modm::ResumableResult< bool > setRfFrequency (uint32_t rfFrequency)
 
modm::ResumableResult< bool > setTxParams (uint8_t power, RampTime rampTime)
 
modm::ResumableResult< bool > setCadParams (CadSymbolNumber cadSymbolNumber)
 Set the number of symbols on which which Channel Activity Detected (CAD) operates.
 
modm::ResumableResult< bool > setBufferBaseAddress (uint8_t txBaseAddress, uint8_t rxBaseAddress)
 Set the base address for the packet handling operation in Tx and Rx mode for all packet types.
 
modm::ResumableResult< bool > setModulationParams (ModulationParams modulationParams)
 
modm::ResumableResult< bool > setPacketParams (PacketParams packetParams)
 
modm::ResumableResult< bool > getRxBufferStatus (RxBufferStatus *rxBufferStatus)
 Get length of the last received packet and the address of the first byte received.
 
modm::ResumableResult< bool > getPacketStatus (PacketStatus *packetStatus)
 
modm::ResumableResult< bool > getRssiInst (uint8_t *rssiInst)
 
modm::ResumableResult< bool > setDioIrqParams (Irq_t irqMask, Irq_t dio1Mask=Irq_t (), Irq_t dio2Mask=Irq_t (), Irq_t dio3Mask=Irq_t ())
 Enable IRQs and to route IRQs to DIO pins.
 
modm::ResumableResult< bool > getIrqStatus (Irq_t *irqStatus)
 Get the value of the IRQ register.
 
modm::ResumableResult< bool > clearIrqStatus (Irq_t irqMask)
 Clear IRQ flags in the IRQ register.
 
modm::ResumableResult< bool > setRegulatorMode (RegulatorMode regModeParam)
 Specify if DC-DC or LDO is used for power regulation.
 
modm::ResumableResult< bool > setSaveContext ()
 Save the present context of the radio register values to the Data RAM.
 
modm::ResumableResult< bool > setAutoFs (bool enable=true)
 
modm::ResumableResult< bool > setAutoTx (uint16_t time)
 
modm::ResumableResult< bool > setLongPreamble (bool enable=true)
 
modm::ResumableResult< bool > setUartSpeed (UartDividerRatio uartDividerRatio)
 
modm::ResumableResult< bool > setRangingRole (RangingRole rangingRole)
 Set the role of the radio in ranging operation.
 
modm::ResumableResult< bool > setAdvancedRanging (bool enable=true)
 Enable advanced ranging.
 
 MODM_FLAGS8 (SleepConfig)
 
 MODM_FLAGS16 (Irq)
 

Static Public Attributes

static constexpr float frequencyLsb = float(52_MHz) / 262144.f
 

Detailed Description

template<class Transport, class Reset, class Busy>
struct modm::Sx128x< Transport, Reset, Busy >

Template Parameters
TransportTranspot Layer for SX128x
Author
Lasse Alexander Jensen
Rasmus Kleist Hørlyck Sørensen

Member Function Documentation

template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::getPacketStatus ( PacketStatus packetStatus)

Retrieve information about the last received packet

Attention
The returned parameters are frame-dependent
Actual signal power is -(rssiSync) / 2 (dBm)
Actual SNR is (snr) / 4 (dBm)
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::getRssiInst ( uint8_t *  rssiInst)

Get the instantaneous RSSI value during reception of the packet

Attention
Actual signal power is -(rssiSync) / 2 (dBm)
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::getStatus ( Status status)

Get the transceiver status directly.

Attention
this command can be issued at any time as long as it is not the very first command send over the interface
template<class Transport , class Reset , class Busy >
modm::ResumableResult<void> modm::Sx128x< Transport, Reset, Busy >::reset ( )

Reset the transceiver

Attention
It is necessary to reset each radio on a shared bus prior to starting the first SPI communicatio
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setAutoFs ( bool  enable = true)

Set the chip so that the state following a Rx or Tx operation is FS and not STDBY This feature is to be used to reduce the switching time between consecutive Rx and/or Tx operations

template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setAutoTx ( uint16_t  time)

Set the device to be able to send back a response 150 us after a packet reception

Attention
The delay between the packet reception end and the next packet transmission start is defined by TxDelay = time + 33 us
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setCad ( )

Set the transceiver to use CAD (Channel Activity Detection) mode

Warning
The Channel Activity Detection is a LoRa specific mode of operation
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setFs ( )

Set the device in Frequency Synthesizer mode where the PLL is locked to the carrier frequency

Attention
In normal operation of the transceiver, the user does not normally need to use FS mode
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setLongPreamble ( bool  enable = true)

Set the transceiver into Long Preamble mode

Warning
Long Preamble mode can only be used with either LoRa mode and GFSK mode
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setModulationParams ( ModulationParams  modulationParams)

Set the modulation parameters of the radio

Attention
The modulation parameters will be interpreted depending on the frame type
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setPacketParams ( PacketParams  packetParams)

Set the parameters of the packet handling block

Warning
Interpretation by the transceiver of the packet parameters depends upon the chosen packet type
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setPacketType ( PacketType  packetType)

Set the transceiver radio frame out of a choice of 5 different packet types

Attention
the packet type must be set first in the radio configuration sequence
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setRfFrequency ( uint32_t  rfFrequency)

Set the frequency of the RF frequency mode.

Warning
This must be called after SetPacket type.
Attention
The LSB of rfFrequency is equal to the PLL step i.e. 52e6/2^18 Hz, where 52e6 is the crystal frequency in Hz
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setRx ( PeriodBase  periodBase,
uint16_t  periodBaseCount 
)

Set the device in Receiver mode

Warning
The IRQ status must be cleared before using this command
Attention
Setting periodBaseCount = 0 puts the transceiver in RX Single Mode
Setting periodBaseCount = 0xFFFF puts the transceiver in Rx Continuous mode
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setRxDutyCycle ( PeriodBase  periodBase,
uint16_t  rxPeriodBaseCount,
uint16_t  sleepPeriodBaseCount 
)

Set the transceiver in sniff mode, so that it regularly looks for new packets

Warning
RxDone interrupt must be configured prior to enter Duty cycled operations
SetLongPreamble must be issued prior to setRxDutyCycle
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setSleep ( SleepConfig_t  sleepConfig)

Set the transceiver to Sleep mode with the lowest current consumption possible

Warning
Depending on the specified level of memory retention not all instruction will be retained
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setStandby ( StandbyConfig  standbyConfig = StandbyConfig::StdbyRc)

Set the device in either STDBY_RC or STDBY_XOSC mode which are intermediate levels of power consumption By default in this state, the system is clocked by the 13 MHz RC oscillator to reduce power consumption. However if the application is time critical, the XOSC block can be turned or left ON.

Attention
In this Standby mode, the transceiver may be configured for future RF operations
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setTx ( PeriodBase  periodBase,
uint16_t  periodBaseCount 
)

Set the device in Transmit mode

Warning
The IRQ status must be cleared before using this command
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setTxContinuousPreamble ( )

Set the transceiver to generate an infinite sequence of alternating 'O's and '1's in GFSK modulation and symbol 0 in LoRa

Attention
The device remains in transmit until the host sends a mode confiquration command
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setTxContinuousWave ( )

Set the transceiver to generate a Continuous Wave (RF tone) at a selected frequency and output power

Attention
The device remains in Tx Continuous Wave until the host sends a mode confiquration command.
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setTxParams ( uint8_t  power,
RampTime  rampTime 
)

Set the Tx output power and the Tx ramp time

Attention
The output power (Pout) is defined by the parameter power. Pout = -18 + power
PoutMin = -18 dBm (power = 0) and PoutMax = 13 dBm (power = 31)
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::setUartSpeed ( UartDividerRatio  uartDividerRatio)

Set UART speed

Warning
UART only
Attention
UART communication must be initiated with 115.2 kbps
The UartDividerRatio is given by UartDividerRatio = (Baud Rate * 2^20) / fClk
template<class Transport , class Reset , class Busy >
modm::ResumableResult<bool> modm::Sx128x< Transport, Reset, Busy >::writeBuffer ( uint8_t  offset,
std::span< const uint8_t >  data 
)

This function is used to write the data payload to be transmitted

Attention
When the address exceeds 255 it wraps back to 0 due to the circular nature of data buffer

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