F439_CPP_TX-RX_LoRa_Project

Loading...
Searching...
No Matches
Macros | Functions | Variables
sx1262.c File Reference
Firmware Architecture » SX1262 Driver Layer

SX1262 LoRa radio driver implementation. More...

`#include <main.h>`
`#include "sx1262.h"`
`#include <stdio.h>`
`#include <string.h>`
Include dependency graph for sx1262.c:

## Macros
#define | SX126X_CMD_SET_STANDBY 0x80
#define | SX126X_CMD_SET_PACKETTYPE 0x8A
#define | SX126X_CMD_SET_RF_FREQUENCY 0x86
#define | SX126X_CMD_SET_BUFFER_BASE_ADDRESS 0x8F
#define | SX126X_CMD_SET_MODULATION_PARAMS 0x8B
#define | SX126X_CMD_SET_PACKET_PARAMS 0x8C
#define | SX126X_CMD_SET_DIO_IRQ_PARAMS 0x08
#define | SX126X_CMD_SET_TX 0x83
#define | SX126X_CMD_SET_RX 0x82
#define | SX126X_CMD_GET_IRQ_STATUS 0x12
#define | SX126X_CMD_CLEAR_IRQ_STATUS 0x02
#define | SX126X_CMD_WRITE_BUFFER 0x0E
#define | SX126X_CMD_READ_BUFFER 0x1E
#define | SX126X_CMD_GET_RX_BUFFER_STATUS 0x13
#define | SX126X_CMD_GET_PACKET_STATUS 0x14
#define | SX126X_CMD_SET_TX_PARAMS 0x8E
#define | SX126X_CMD_SET_RX_TX_FALLBACK_MODE 0x93
#define | SX126X_CMD_SET_REGULATOR_MODE 0x96
#define | SX126X_CMD_SET_PA_CONFIG 0x95
#define | SX126X_CMD_SET_DIO3_AS_TCXO_CTRL 0x97
#define | SX126X_CMD_CALIBRATE_IMAGE 0x98
#define | SX126X_PACKET_LORA 0x01
#define | SX126X_STANDBY_RC 0x00
#define | SX126X_IRQ_TX_DONE (1u << 0)
#define | SX126X_IRQ_RX_DONE (1u << 1)
#define | SX126X_IRQ_CRC_ERROR (1u << 6)
#define | SX126X_IRQ_RX_TX_TIMEOUT (1u << 9)

## Functions
void | SX1262_Init (SX1262_Handle *sx)
| Initialize the SX1262 hardware interface.
bool | SX1262_ConfigureLoRa (SX1262_Handle *sx, const SX1262_LoRaConfig *cfg)
| Configure the SX1262 for LoRa operation.
bool | SX1262_StartRxContinuous (SX1262_Handle *sx)
| Enter continuous receive mode.
bool | SX1262_SendString (SX1262_Handle *sx, const char *s)
| Send a NUL-terminated string through the radio.
bool | SX1262_SendStringPlainText (SX1262_Handle *sx, const char *s)
| Send a plaintext string without RadioLink framing.
bool | SX1262_SendBytes (SX1262_Handle *sx, const uint8_t *buf, uint8_t len)
| Send a raw byte buffer through the radio.
bool | SX1262_SendBuffer (SX1262_Handle *sx, const char *s)
| Send a character buffer through the radio.
bool | SX1262_ProcessIrq (SX1262_Handle *sx, SX1262_IrqResult *out)
| Process a DIO1-driven IRQ event.
uint8_t | SX1262_GetStatusRaw (SX1262_Handle *sx)
| Read the raw radio status byte.
uint16_t | SX1262_GetIrqStatusRaw (SX1262_Handle *sx)
| Read the raw IRQ status bits.
void | SX1262_ClearIrq (SX1262_Handle *sx, uint16_t mask)
| Clear selected IRQ bits.
bool | SX1262_SetStandbyRc (SX1262_Handle *sx)
| Put the radio into RC standby mode.

## Variables
SX1262_ROLE | sx1262Role

## Detailed Description

SX1262 LoRa radio driver implementation.

## Macro Definition Documentation

## ◆ SX126X_CMD_CALIBRATE_IMAGE

#define SX126X_CMD_CALIBRATE_IMAGE 0x98

## ◆ SX126X_CMD_CLEAR_IRQ_STATUS

#define SX126X_CMD_CLEAR_IRQ_STATUS 0x02

## ◆ SX126X_CMD_GET_IRQ_STATUS

#define SX126X_CMD_GET_IRQ_STATUS 0x12

## ◆ SX126X_CMD_GET_PACKET_STATUS

#define SX126X_CMD_GET_PACKET_STATUS 0x14

## ◆ SX126X_CMD_GET_RX_BUFFER_STATUS

#define SX126X_CMD_GET_RX_BUFFER_STATUS 0x13

## ◆ SX126X_CMD_READ_BUFFER

#define SX126X_CMD_READ_BUFFER 0x1E

## ◆ SX126X_CMD_SET_BUFFER_BASE_ADDRESS

#define SX126X_CMD_SET_BUFFER_BASE_ADDRESS 0x8F

## ◆ SX126X_CMD_SET_DIO3_AS_TCXO_CTRL

#define SX126X_CMD_SET_DIO3_AS_TCXO_CTRL 0x97

## ◆ SX126X_CMD_SET_DIO_IRQ_PARAMS

#define SX126X_CMD_SET_DIO_IRQ_PARAMS 0x08

## ◆ SX126X_CMD_SET_MODULATION_PARAMS

#define SX126X_CMD_SET_MODULATION_PARAMS 0x8B

## ◆ SX126X_CMD_SET_PA_CONFIG

#define SX126X_CMD_SET_PA_CONFIG 0x95

## ◆ SX126X_CMD_SET_PACKET_PARAMS

#define SX126X_CMD_SET_PACKET_PARAMS 0x8C

## ◆ SX126X_CMD_SET_PACKETTYPE

#define SX126X_CMD_SET_PACKETTYPE 0x8A

## ◆ SX126X_CMD_SET_REGULATOR_MODE

#define SX126X_CMD_SET_REGULATOR_MODE 0x96

## ◆ SX126X_CMD_SET_RF_FREQUENCY

#define SX126X_CMD_SET_RF_FREQUENCY 0x86

## ◆ SX126X_CMD_SET_RX

#define SX126X_CMD_SET_RX 0x82

## ◆ SX126X_CMD_SET_RX_TX_FALLBACK_MODE

#define SX126X_CMD_SET_RX_TX_FALLBACK_MODE 0x93

## ◆ SX126X_CMD_SET_STANDBY

#define SX126X_CMD_SET_STANDBY 0x80

## ◆ SX126X_CMD_SET_TX

#define SX126X_CMD_SET_TX 0x83

## ◆ SX126X_CMD_SET_TX_PARAMS

#define SX126X_CMD_SET_TX_PARAMS 0x8E

## ◆ SX126X_CMD_WRITE_BUFFER

#define SX126X_CMD_WRITE_BUFFER 0x0E

## ◆ SX126X_IRQ_CRC_ERROR

#define SX126X_IRQ_CRC_ERROR (1u << 6)

## ◆ SX126X_IRQ_RX_DONE

#define SX126X_IRQ_RX_DONE (1u << 1)

## ◆ SX126X_IRQ_RX_TX_TIMEOUT

#define SX126X_IRQ_RX_TX_TIMEOUT (1u << 9)

## ◆ SX126X_IRQ_TX_DONE

#define SX126X_IRQ_TX_DONE (1u << 0)

## ◆ SX126X_PACKET_LORA

#define SX126X_PACKET_LORA 0x01

## ◆ SX126X_STANDBY_RC

#define SX126X_STANDBY_RC 0x00

## Function Documentation

## ◆ SX1262_ClearIrq()

void SX1262_ClearIrq | ( | SX1262_Handle * | sx,
|  | uint16_t | mask )

Clear selected IRQ bits.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.
  mask | IRQ mask bits to clear.

## ◆ SX1262_ConfigureLoRa()

bool SX1262_ConfigureLoRa | ( | SX1262_Handle * | sx,
|  | const SX1262_LoRaConfig * | cfg )

Configure the SX1262 for LoRa operation.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.
  cfg | Requested LoRa modem configuration.

Returns
  true if configuration succeeded, otherwise false.

## ◆ SX1262_GetIrqStatusRaw()

uint16_t SX1262_GetIrqStatusRaw | ( | SX1262_Handle * | sx | ) |

Read the raw IRQ status bits.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.

Returns
  Raw IRQ status mask.

## ◆ SX1262_GetStatusRaw()

uint8_t SX1262_GetStatusRaw | ( | SX1262_Handle * | sx | ) |

Read the raw radio status byte.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.

Returns
  Raw SX1262 status byte.

## ◆ SX1262_Init()

void SX1262_Init | ( | SX1262_Handle * | sx | ) |

Initialize the SX1262 hardware interface.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.

## ◆ SX1262_ProcessIrq()

bool SX1262_ProcessIrq | ( | SX1262_Handle * | sx,
|  | SX1262_IrqResult * | out )

Process a DIO1-driven IRQ event.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.
  out | Output structure populated with decoded IRQ results.

Returns
  true if IRQ handling succeeded, otherwise false.

## ◆ SX1262_SendBuffer()

bool SX1262_SendBuffer | ( | SX1262_Handle * | sx,
|  | const char * | buf )

Send a character buffer through the radio.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.
  buf | Buffer to transmit.

Returns
  true if the send request succeeded, otherwise false.

## ◆ SX1262_SendBytes()

bool SX1262_SendBytes | ( | SX1262_Handle * | sx,
|  | const uint8_t * | buf,
|  | uint8_t | len )

Send a raw byte buffer through the radio.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.
  buf | Buffer to transmit.
  len | Number of bytes to transmit.

Returns
  true if the send request succeeded, otherwise false.

## ◆ SX1262_SendString()

bool SX1262_SendString | ( | SX1262_Handle * | sx,
|  | const char * | s )

Send a NUL-terminated string through the radio.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.
  s | NUL-terminated string to transmit.

Returns
  true if the send request succeeded, otherwise false.

## ◆ SX1262_SendStringPlainText()

bool SX1262_SendStringPlainText | ( | SX1262_Handle * | sx,
|  | const char * | s )

Send a plaintext string without RadioLink framing.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.
  s | NUL-terminated string to transmit.

Returns
  true if the send request succeeded, otherwise false.

## ◆ SX1262_SetStandbyRc()

bool SX1262_SetStandbyRc | ( | SX1262_Handle * | sx | ) |

Put the radio into RC standby mode.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.

Returns
  true if the command succeeded, otherwise false.

## ◆ SX1262_StartRxContinuous()

bool SX1262_StartRxContinuous | ( | SX1262_Handle * | sx | ) |

Enter continuous receive mode.

Parameters

  sx | Driver handle describing the SPI and GPIO bindings.

Returns
  true if the command succeeded, otherwise false.

## Variable Documentation

## ◆ sx1262Role

SX1262_ROLE sx1262Role
| extern