SX126x-Arduino  2.0.1
Functions | Variables
sx126x-board.cpp File Reference
#include <Arduino.h>
#include "boards/mcu/board.h"
#include "boards/mcu/spi_board.h"
#include "radio/sx126x/sx126x.h"
#include "sx126x-board.h"

Functions

void SX126xIoInit (void)
 Initializes the radio I/Os pins interface. More...
 
void SX126xIoReInit (void)
 Initializes the radio I/Os pins interface after deep sleep wake. More...
 
void SX126xIoIrqInit (DioIrqHandler dioIrq)
 Initializes DIO IRQ handlers. More...
 
void SX126xIoDeInit (void)
 De-initializes the radio I/Os pins interface. More...
 
void SX126xReset (void)
 HW Reset of the radio. More...
 
void SX126xWaitOnBusy (void)
 Blocking loop to wait while the Busy pin in high. More...
 
void SX126xWakeup (void)
 Wakes up the radio. More...
 
void SX126xWriteCommand (RadioCommands_t command, uint8_t *buffer, uint16_t size)
 Send a command that write data to the radio. More...
 
void SX126xReadCommand (RadioCommands_t command, uint8_t *buffer, uint16_t size)
 Send a command that read data from the radio. More...
 
void SX126xWriteRegisters (uint16_t address, uint8_t *buffer, uint16_t size)
 Write data to the radio memory. More...
 
void SX126xWriteRegister (uint16_t address, uint8_t value)
 Write a single byte of data to the radio memory. More...
 
void SX126xReadRegisters (uint16_t address, uint8_t *buffer, uint16_t size)
 Read data from the radio memory. More...
 
uint8_t SX126xReadRegister (uint16_t address)
 Read a single byte of data from the radio memory. More...
 
void SX126xWriteBuffer (uint8_t offset, uint8_t *buffer, uint8_t size)
 Write data to the buffer holding the payload in the radio. More...
 
void SX126xReadBuffer (uint8_t offset, uint8_t *buffer, uint8_t size)
 Read data from the buffer holding the payload in the radio. More...
 
void SX126xSetRfTxPower (int8_t power)
 Sets the radio output power. More...
 
uint8_t SX126xGetPaSelect (uint32_t channel)
 Gets the board PA selection configuration. More...
 
static void SX126xDio3Control (bool state)
 
void SX126xAntSwOn (void)
 Initializes the RF Switch I/Os pins interface. More...
 
void SX126xAntSwOff (void)
 De-initializes the RF Switch I/Os pins interface. More...
 
void SX126xRXena (void)
 Set the RF antenna switch to receiving mode. More...
 
void SX126xTXena (void)
 Set the RF antenna switch to transmitting mode. More...
 
bool SX126xCheckRfFrequency (uint32_t frequency)
 Checks if the given RF frequency is supported by the hardware. More...
 
void SX126xGetStats (uint16_t *nb_pkt_received, uint16_t *nb_pkt_crc_error, uint16_t *nb_pkt_length_error)
 Gets info on the number of packets received. More...
 
void SX126xResetStats (void)
 Resets values read by GetStats. More...
 

Variables

SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0)
 
bool dio3IsOutput = false
 

Function Documentation

◆ SX126xIoInit()

void SX126xIoInit ( void  )

Initializes the radio I/Os pins interface.

◆ SX126xIoReInit()

void SX126xIoReInit ( void  )

Initializes the radio I/Os pins interface after deep sleep wake.

◆ SX126xIoIrqInit()

void SX126xIoIrqInit ( DioIrqHandler  dioIrq)

Initializes DIO IRQ handlers.

Parameters
dioIrqArray containing the IRQ callback functions

◆ SX126xIoDeInit()

void SX126xIoDeInit ( void  )

De-initializes the radio I/Os pins interface.

Remarks
Useful when going in MCU low power modes

◆ SX126xReset()

void SX126xReset ( void  )

HW Reset of the radio.

◆ SX126xWaitOnBusy()

void SX126xWaitOnBusy ( void  )

Blocking loop to wait while the Busy pin in high.

Todo:
This error should be reported to the main app

◆ SX126xWakeup()

void SX126xWakeup ( void  )

Wakes up the radio.

◆ SX126xWriteCommand()

void SX126xWriteCommand ( RadioCommands_t  opcode,
uint8_t *  buffer,
uint16_t  size 
)

Send a command that write data to the radio.

Parameters
opcodeOpcode of the command
bufferBuffer to be send to the radio
sizeSize of the buffer to send

◆ SX126xReadCommand()

void SX126xReadCommand ( RadioCommands_t  opcode,
uint8_t *  buffer,
uint16_t  size 
)

Send a command that read data from the radio.

Parameters
opcodeOpcode of the command
bufferBuffer holding data from the radio
sizeSize of the buffer

◆ SX126xWriteRegisters()

void SX126xWriteRegisters ( uint16_t  address,
uint8_t *  buffer,
uint16_t  size 
)

Write data to the radio memory.

Parameters
addressThe address of the first byte to write in the radio
bufferThe data to be written in radio's memory
sizeThe number of bytes to write in radio's memory

◆ SX126xWriteRegister()

void SX126xWriteRegister ( uint16_t  address,
uint8_t  value 
)

Write a single byte of data to the radio memory.

Parameters
addressThe address of the first byte to write in the radio
valueThe data to be written in radio's memory

◆ SX126xReadRegisters()

void SX126xReadRegisters ( uint16_t  address,
uint8_t *  buffer,
uint16_t  size 
)

Read data from the radio memory.

Parameters
addressThe address of the first byte to read from the radio
bufferThe buffer that holds data read from radio
sizeThe number of bytes to read from radio's memory

◆ SX126xReadRegister()

uint8_t SX126xReadRegister ( uint16_t  address)

Read a single byte of data from the radio memory.

Parameters
addressThe address of the first byte to write in the radio
Return values
valueThe value of the byte at the given address in radio's memory

◆ SX126xWriteBuffer()

void SX126xWriteBuffer ( uint8_t  offset,
uint8_t *  buffer,
uint8_t  size 
)

Write data to the buffer holding the payload in the radio.

Parameters
offsetThe offset to start writing the payload
bufferThe data to be written (the payload)
sizeThe number of byte to be written

◆ SX126xReadBuffer()

void SX126xReadBuffer ( uint8_t  offset,
uint8_t *  buffer,
uint8_t  size 
)

Read data from the buffer holding the payload in the radio.

Parameters
offsetThe offset to start reading the payload
bufferA pointer to a buffer holding the data from the radio
sizeThe number of byte to be read

◆ SX126xSetRfTxPower()

void SX126xSetRfTxPower ( int8_t  power)

Sets the radio output power.

Parameters
powerSets the RF output power

◆ SX126xGetPaSelect()

uint8_t SX126xGetPaSelect ( uint32_t  channel)

Gets the board PA selection configuration.

Parameters
channelChannel frequency in Hz
Return values
PaSelectRegPaConfig PaSelect value

◆ SX126xDio3Control()

static void SX126xDio3Control ( bool  state)
static

◆ SX126xAntSwOn()

void SX126xAntSwOn ( void  )

Initializes the RF Switch I/Os pins interface.

◆ SX126xAntSwOff()

void SX126xAntSwOff ( void  )

De-initializes the RF Switch I/Os pins interface.

Remarks
Needed to decrease the power consumption in MCU low power modes

◆ SX126xRXena()

void SX126xRXena ( void  )

Set the RF antenna switch to receiving mode.

Remarks
Used only on some modules e.g. eByte E22

◆ SX126xTXena()

void SX126xTXena ( void  )

Set the RF antenna switch to transmitting mode.

Remarks
Used only on some modules e.g. eByte E22

◆ SX126xCheckRfFrequency()

bool SX126xCheckRfFrequency ( uint32_t  frequency)

Checks if the given RF frequency is supported by the hardware.

Parameters
frequencyRF frequency to be checked
Return values
isSupported[true: supported, false: unsupported]

◆ SX126xGetStats()

void SX126xGetStats ( uint16_t *  nb_pkt_received,
uint16_t *  nb_pkt_crc_error,
uint16_t *  nb_pkt_length_error 
)

Gets info on the number of packets received.

Parameters
nb_pkt_receivedNumber of received packets with CRC OK
nb_pkt_crc_errorNumber of received packets with CRC error
nb_pkt_length_errorNumber of received packets with length error

◆ SX126xResetStats()

void SX126xResetStats ( void  )

Resets values read by GetStats.

Variable Documentation

◆ spiSettings

SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0)

◆ dio3IsOutput

bool dio3IsOutput = false