16#define SX1272_REG_END 0x46
18#define SX1272_REG_FIFO 0x00
19#define SX1272_REG_FIFO_ADDR_PTR 0x0D
20#define SX1272_REG_FIFO_TX_BASE_ADDR 0x0E
21#define SX1272_REG_FIFO_RX_BASE_ADDR 0x0F
22#define SX1272_REG_FIFO_RX_CURR_ADDR 0x10
24#define SX1272_REG_RX_BYTES 0x13
26#define SX1272_REG_DIO_MAPPING1 0x40
27#define SX1272_DIO_MAPPING_DIO0_Pos 0x06
28#define SX1272_DIO_MAPPING_DIO1_Pos 0x04
29#define SX1272_DIO_MAPPING_DIO2_Pos 0x02
30#define SX1272_DIO_MAPPING_DIO3_Pos 0x00
31#define SX1272_DIO_MAPPING_DIO4_Pos 0x06
32#define SX1272_DIO_MAPPING_DIO5_Pos 0x04
34#define SX1272_LORA_DIO_RXDONE 0x00 << SX1272_DIO_MAPPING_DIO0_Pos
35#define SX1272_LORA_DIO_TXDONE 0x01 << SX1272_DIO_MAPPING_DIO0_Pos
37#define SX1272_REG_IRQ_FLAGS_MASK 0x11
38#define SX1272_REG_IRQ_FLAGS 0x12
39#define SX1272_LORA_IRQ_RXDONE 0x40
40#define SX1272_LORA_IRQ_TXDONE 0x08
42#define SX1272_REG_OP_MODE 0x01
43#define SX1272_OP_MODE_LONG_RANGE 0x80
44#define SX1272_OP_MODE_MODE_Pos 0x00
46#define SX1272_REG_OCP 0x0B
47#define SX1272_OCP_ON 0x20
48#define SX1272_OCP_TRIM 0x1F
50#define SX1272_REG_FR_MSB 0x06
51#define SX1272_REG_FR_MIB 0x07
52#define SX1272_REG_FR_LSB 0x08
54#define SX1272_REG_MODEM_CONFIG1 0x1D
55#define SX1272_MODEM_CONFIG1_CRC 0x02
56#define SX1272_MODEM_CONFIG1_IMPLICIT_HEADER 0x04
57#define SX1272_MODEM_CONFIG1_BW_Pos 0x06
58#define SX1272_MODEM_CONFIG1_CR_Pos 0x03
60#define SX1272_REG_MODEM_CONFIG2 0x1E
61#define SX1272_MODEM_CONFIG2_AGC_AUTO_ON 0x04
62#define SX1272_MODEM_CONFIG2_SF_Pos 0x04
64#define SX1272_REG_PA_CONFIG 0x09
65#define SX1272_PA_SELECT 0x80
67#define SX1272_REG_LNA 0x0C
69#define SX1272_REG_PAYLOAD_LENGTH 0x22
70#define SX1272_REG_MAX_PAYLOAD_LENGTH 0x23
72#define SX1272_REG_PA_DAC 0x5A
78#define SX1272_CONFIG_DEFAULT \
84 .implicitHeader = false, \
87 .outputPower = 0x1F, \
90 .rxFifoBaseAddr = 0x00, \
91 .txFifoBaseAddr = 0x00, \
92 .maxPayloadLength = 0x20 \
150 SX1272_MODE_RXCONTINUOUS,
151 SX1272_MODE_RXSINGLE,
189typedef struct SX1272 {
211uint8_t SX1272_readRegister(
SX1272_t *, uint8_t);
Struct definition for a GPIO pin.
SX1272_CodingRate cr
SX1272 LoRa modem coding rate.
uint8_t ocpTrim
SX1272 LoRa modem overcurrent protection trim.
SX1272_Config config
Configuration parameters for the SX1272 driver.
void(* standby)(struct SX1272 *)
SX1272 standby method.
float freq
SX1272 LoRa carrier frequency.
SX1272_SpreadingFactor sf
SX1272 LoRa modem spreading factor.
GPIOpin_t cs
Chip select GPIO.
LoRa_t base
Base LoRa API.
uint8_t rxFifoBaseAddr
Base address for RX fifo.
bool ocp
SX1272 LoRa modem overcurrent protection enable.
bool(* updateConfig)(struct SX1272 *, SX1272_Config *)
SX1272 configuration update method.
bool paSelect
SX1272 LoRa modem power amp output select.
uint8_t outputPower
SX1272 LoRa modem power amp output power.
bool implicitHeader
SX1272 LoRa modem implicit header enable.
uint8_t txFifoBaseAddr
Base address for TX fifo.
SX1272_Mode currentMode
Current operating mode.
SX1272_Bandwidth bw
SX1272 LoRa modem bandwidth.
SPI_t * spi
Parent SPI interface.
bool crc
SX1272 LoRa modem CRC enable.
uint8_t maxPayloadLength
Maximum allowed length of payload.
Struct definition for SPI interface. Provides the interface for API consumers to interact with the SP...
SX1272_Bandwidth
SX1272 bandwidth enum.
void SX1272_startReceive(LoRa_t *lora)
Begins continuous receive on the SX1272.
uint8_t SX1272_readReceive(LoRa_t *lora, uint8_t *data, uint8_t byffSize)
Reads contents of received packet to local buffer from the SX1272.
void SX1272_transmit(LoRa_t *lora, uint8_t *data, uint8_t length)
Transmits data using the SX1272.
SX1272_SpreadingFactor
SX1272 spreading factor enum.
bool SX1272_updateConfig(SX1272_t *lora, SX1272_Config *config)
Update SX1272 configuration.
SX1272_Mode
SX1272 operating mode enum.
void SX1272_standby(SX1272_t *)
Sets the operational mode of the LoRa module to standby.
SX1272_CodingRate
SX1272 coding rate enum.
bool SX1272_init(SX1272_t *lora, SPI_t *spi, GPIOpin_t cs, SX1272_Config *config)
Initializes the LoRa module with specified configuration parameters.
void SX1272_clearIRQ(LoRa_t *, uint8_t)
Sets the value of RegIrqFlags in the SX1272 to the provided argument value. Writing a 1 to a bit in t...
SX1272 LoRa configuration struct.
Struct definition for SX1272. Provides the interface for API consumers to interact with the SX1272 Lo...
Defines the API for LoRa communication.