Public interface for SX127X driver. More...
Public interface for SX127X driver.
Definition in file sx127x.h.
#include "timex.h"
#include "ztimer.h"
#include "net/netdev.h"
#include "periph/gpio.h"
#include "periph/spi.h"
Go to the source code of this file.
Data Structures | |
struct | sx127x_lora_settings_t |
LoRa configuration structure. More... | |
struct | sx127x_radio_settings_t |
Radio settings. More... | |
struct | sx127x_internal_t |
SX127X internal data. More... | |
struct | sx127x_params_t |
SX127X hardware and global parameters. More... | |
struct | sx127x_t |
SX127X device descriptor. More... | |
Macros | |
#define | SX127X_DIO_PULL_MODE (GPIO_IN_PD) |
GPIO mode of DIOx Pins. | |
Typedefs | |
typedef uint8_t | sx127x_flags_t |
SX127X IRQ flags. | |
typedef void() | sx127x_dio_irq_handler_t(sx127x_t *dev) |
Hardware IO IRQ callback function definition. | |
Enumerations | |
enum | { SX127X_INIT_OK = 0, SX127X_ERR_SPI, SX127X_ERR_GPIOS, SX127X_ERR_NODEV } |
SX127X initialization result. More... | |
enum | { SX127X_MODEM_FSK = 0, SX127X_MODEM_LORA } |
Radio driver supported modems. More... | |
enum | { SX127X_RF_IDLE = 0, SX127X_RF_RX_RUNNING, SX127X_RF_TX_RUNNING, SX127X_RF_CAD } |
Radio driver internal state machine states definition. More... | |
enum | { SX127X_RX_DONE = 0, SX127X_TX_DONE, SX127X_RX_TIMEOUT, SX127X_TX_TIMEOUT, SX127X_RX_ERROR_CRC, SX127X_FHSS_CHANGE_CHANNEL, SX127X_CAD_DONE } |
Event types. More... | |
enum | { SX127X_PA_RFO = 0, SX127X_PA_BOOST } |
Power amplifier modes. More... | |
Functions | |
void | sx127x_setup (sx127x_t *dev, const sx127x_params_t *params) |
Setup the SX127X. More... | |
int | sx127x_reset (const sx127x_t *dev) |
Resets the SX127X. More... | |
int | sx127x_init (sx127x_t *dev) |
Initializes the transceiver. More... | |
void | sx127x_init_radio_settings (sx127x_t *dev) |
Initialize radio settings with default values. More... | |
uint32_t | sx127x_random (sx127x_t *dev) |
Generates 32 bits random value based on the RSSI readings. More... | |
void | sx127x_start_cad (sx127x_t *dev) |
Start a channel activity detection. More... | |
bool | sx127x_is_channel_free (sx127x_t *dev, uint32_t freq, int16_t rssi_threshold) |
Checks that channel is free with specified RSSI threshold. More... | |
int16_t | sx127x_read_rssi (const sx127x_t *dev) |
Reads the current RSSI value. More... | |
uint8_t | sx127x_get_state (const sx127x_t *dev) |
Gets current state of transceiver. More... | |
void | sx127x_set_state (sx127x_t *dev, uint8_t state) |
Sets current state of transceiver. More... | |
void | sx127x_set_modem (sx127x_t *dev, uint8_t modem) |
Configures the radio with the given modem. More... | |
uint8_t | sx127x_get_syncword (const sx127x_t *dev) |
Gets the synchronization word. More... | |
void | sx127x_set_syncword (sx127x_t *dev, uint8_t syncword) |
Sets the synchronization word. More... | |
uint32_t | sx127x_get_channel (const sx127x_t *dev) |
Gets the channel RF frequency. More... | |
void | sx127x_set_channel (sx127x_t *dev, uint32_t freq) |
Sets the channel RF frequency. More... | |
uint32_t | sx127x_get_time_on_air (const sx127x_t *dev, uint8_t pkt_len) |
Computes the packet time on air in milliseconds. More... | |
void | sx127x_set_sleep (sx127x_t *dev) |
Sets the radio in sleep mode. More... | |
void | sx127x_set_standby (sx127x_t *dev) |
Sets the radio in stand-by mode. More... | |
void | sx127x_set_rx (sx127x_t *dev) |
Sets the radio in reception mode. More... | |
void | sx127x_set_tx (sx127x_t *dev) |
Sets the radio in transmission mode. More... | |
uint8_t | sx127x_get_max_payload_len (const sx127x_t *dev) |
Gets the maximum payload length. More... | |
void | sx127x_set_max_payload_len (const sx127x_t *dev, uint8_t maxlen) |
Sets the maximum payload length. More... | |
uint8_t | sx127x_get_op_mode (const sx127x_t *dev) |
Gets the SX127X operating mode. More... | |
void | sx127x_set_op_mode (const sx127x_t *dev, uint8_t op_mode) |
Sets the SX127X operating mode. More... | |
uint8_t | sx127x_get_bandwidth (const sx127x_t *dev) |
Gets the SX127X bandwidth. More... | |
void | sx127x_set_bandwidth (sx127x_t *dev, uint8_t bandwidth) |
Sets the SX127X bandwidth. More... | |
uint8_t | sx127x_get_spreading_factor (const sx127x_t *dev) |
Gets the SX127X LoRa spreading factor. More... | |
void | sx127x_set_spreading_factor (sx127x_t *dev, uint8_t sf) |
Sets the SX127X LoRa spreading factor. More... | |
uint8_t | sx127x_get_coding_rate (const sx127x_t *dev) |
Gets the SX127X LoRa coding rate. More... | |
void | sx127x_set_coding_rate (sx127x_t *dev, uint8_t coderate) |
Sets the SX127X LoRa coding rate. More... | |
bool | sx127x_get_rx_single (const sx127x_t *dev) |
Checks if the SX127X LoRa RX single mode is enabled/disabled. More... | |
void | sx127x_set_rx_single (sx127x_t *dev, bool single) |
Enable/disable the SX127X LoRa RX single mode. More... | |
bool | sx127x_get_crc (const sx127x_t *dev) |
Checks if the SX127X CRC verification mode is enabled. More... | |
void | sx127x_set_crc (sx127x_t *dev, bool crc) |
Enable/Disable the SX127X CRC verification mode. More... | |
uint8_t | sx127x_get_hop_period (const sx127x_t *dev) |
Gets the SX127X frequency hopping period. More... | |
void | sx127x_set_hop_period (sx127x_t *dev, uint8_t hop_period) |
Sets the SX127X frequency hopping period. More... | |
bool | sx127x_get_fixed_header_len_mode (const sx127x_t *dev) |
Gets the SX127X LoRa fixed header length mode. More... | |
void | sx127x_set_fixed_header_len_mode (sx127x_t *dev, bool mode) |
Sets the SX127X to fixed header length mode (explicit mode) More... | |
uint8_t | sx127x_get_payload_length (const sx127x_t *dev) |
Gets the SX127X payload length. More... | |
void | sx127x_set_payload_length (sx127x_t *dev, uint8_t len) |
Sets the SX127X payload length. More... | |
uint8_t | sx127x_get_tx_power (const sx127x_t *dev) |
Gets the SX127X TX radio power. More... | |
void | sx127x_set_tx_power (sx127x_t *dev, int8_t power) |
Sets the SX127X transmission power. More... | |
uint16_t | sx127x_get_preamble_length (const sx127x_t *dev) |
Gets the SX127X preamble length. More... | |
void | sx127x_set_preamble_length (sx127x_t *dev, uint16_t preamble) |
Sets the SX127X LoRa preamble length. More... | |
void | sx127x_set_symbol_timeout (sx127x_t *dev, uint16_t timeout) |
Sets the SX127X LoRa symbol timeout. More... | |
void | sx127x_set_rx_timeout (sx127x_t *dev, uint32_t timeout) |
Sets the SX127X RX timeout. More... | |
void | sx127x_set_tx_timeout (sx127x_t *dev, uint32_t timeout) |
Sets the SX127X TX timeout. More... | |
bool | sx127x_get_iq_invert (const sx127x_t *dev) |
Checks if the SX127X LoRa inverted IQ mode is enabled/disabled. More... | |
void | sx127x_set_iq_invert (sx127x_t *dev, bool iq_invert) |
Enable/disable the SX127X LoRa IQ inverted mode. More... | |
void | sx127x_set_freq_hop (sx127x_t *dev, bool freq_hop_on) |
Sets the SX127X LoRa frequency hopping mode. More... | |
SX127X device default configuration | |
#define | SX127X_MODEM_DEFAULT (SX127X_MODEM_LORA) |
Use LoRa as default modem. | |
#define | SX127X_CHANNEL_DEFAULT (868300000UL) |
Default channel frequency, 868.3MHz (Europe) | |
#define | SX127X_HF_CHANNEL_DEFAULT (868000000UL) |
Use to calibrate RX chain for LF and HF bands. | |
#define | SX127X_RF_MID_BAND_THRESH (525000000UL) |
Mid-band threshold. | |
#define | SX127X_XTAL_FREQ (32000000UL) |
Internal oscillator frequency, 32MHz. | |
#define | SX127X_RADIO_WAKEUP_TIME (1U) |
In milliseconds [ms]. | |
#define | SX127X_TX_TIMEOUT_DEFAULT (30 * MS_PER_SEC) |
TX timeout, 30s. | |
#define | SX127X_RX_SINGLE (false) |
Single byte receive mode => continuous by default. | |
#define | SX127X_RX_BUFFER_SIZE (256) |
RX buffer size. | |
#define | SX127X_RADIO_TX_POWER (14U) |
Radio power in dBm. | |
#define | SX127X_EVENT_HANDLER_STACK_SIZE (2048U) |
Stack size event handler. | |
#define | SX127X_IRQ_DIO0 (1<<0) |
DIO0 IRQ. | |
#define | SX127X_IRQ_DIO1 (1<<1) |
DIO1 IRQ. | |
#define | SX127X_IRQ_DIO2 (1<<2) |
DIO2 IRQ. | |
#define | SX127X_IRQ_DIO3 (1<<3) |
DIO3 IRQ. | |
#define | SX127X_IRQ_DIO4 (1<<4) |
DIO4 IRQ. | |
#define | SX127X_IRQ_DIO5 (1<<5) |
DIO5 IRQ. | |