Pico GPS Teseo I2C
Loading...
Searching...
No Matches
sx1280-hal.c File Reference
#include "hw.h"
#include "sx1280-hal.h"
#include "radio.h"
#include <string.h>
#include "SEGGER_RTT.h"
Include dependency graph for sx1280-hal.c:

Go to the source code of this file.

Macros

#define printf(format, ...)
 
#define RADIO_BUSY_PORT   RADIO_BUSY_GPIO_Port
 
#define RADIO_BUSY_PIN   RADIO_BUSY_Pin
 
#define RADIO_nRESET_PORT   RADIO_nRESET_GPIO_Port
 
#define RADIO_nRESET_PIN   RADIO_nRESET_Pin
 
#define RADIO_NSS_PORT   RADIO_NSS_GPIO_Port
 
#define RADIO_NSS_PIN   RADIO_NSS_Pin
 
#define MAX_HAL_BUFFER_SIZE   0xFFF
 Define the size of tx and rx hal buffers.
 
#define IRQ_HIGH_PRIORITY   0
 

Functions

void SX1280HalSpiTxThenRx (uint16_t tx_len, uint8_t *rx_buffer, uint16_t rx_len)
 
void SX1280HalWaitOnBusy (void)
 Used to block execution waiting for low state on radio busy pin. Essentially used in SPI communications.
 
void SX1280HalInit (DioIrqHandler **irqHandlers)
 
void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin)
 
void SX1280HalIoIrqInit (DioIrqHandler **irqHandlers)
 
void SX1280HalReset (void)
 Soft resets the radio.
 
void SX1280HalWakeup (void)
 Wakes up the radio.
 
void SX1280HalWriteCommand (RadioCommands_t command, uint8_t *buffer, uint16_t size)
 Send a command that write data to the radio.
 
void SX1280HalReadCommand (RadioCommands_t command, uint8_t *buffer, uint16_t size)
 Send a command that read data from the radio.
 
void SX1280HalWriteRegisters (uint16_t address, uint8_t *buffer, uint16_t size)
 Write data to the radio memory.
 
void SX1280HalWriteRegister (uint16_t address, uint8_t value)
 Write a single byte of data to the radio memory.
 
void SX1280HalReadRegisters (uint16_t address, uint8_t *buffer, uint16_t size)
 Read data from the radio memory.
 
uint8_t SX1280HalReadRegister (uint16_t address)
 Read a single byte of data from the radio memory.
 
void SX1280HalWriteBuffer (uint8_t offset, uint8_t *buffer, uint8_t size)
 Write data to the buffer holding the payload in the radio.
 
void SX1280HalReadBuffer (uint8_t offset, uint8_t *buffer, uint8_t size)
 Read data from the buffer holding the payload in the radio.
 
uint8_t SX1280HalGetDioStatus (void)
 Returns the status of DIOs pins.
 

Variables

const struct Radio_s Radio
 Radio driver.
 
SPI_HandleTypeDef RADIO_SPI_HANDLE
 
DMA_HandleTypeDef RADIO_SPI_DMA_RX
 
DMA_HandleTypeDef RADIO_SPI_DMA_TX
 

Macro Definition Documentation

◆ IRQ_HIGH_PRIORITY

#define IRQ_HIGH_PRIORITY   0

Definition at line 55 of file sx1280-hal.c.

◆ MAX_HAL_BUFFER_SIZE

#define MAX_HAL_BUFFER_SIZE   0xFFF

Define the size of tx and rx hal buffers.

The Tx and Rx hal buffers are used for SPI communication to store data to be sent/receive to/from the chip.

Warning
The application must ensure the maximal useful size to be much lower than the MAX_HAL_BUFFER_SIZE

Definition at line 53 of file sx1280-hal.c.

◆ printf

#define printf ( format,
... )
Value:
SEGGER_RTT_printf(0, format, ## __VA_ARGS__)
int SEGGER_RTT_printf(unsigned BufferIndex, const char *sFormat,...)

Definition at line 23 of file sx1280-hal.c.

◆ RADIO_BUSY_PIN

#define RADIO_BUSY_PIN   RADIO_BUSY_Pin

Definition at line 30 of file sx1280-hal.c.

◆ RADIO_BUSY_PORT

#define RADIO_BUSY_PORT   RADIO_BUSY_GPIO_Port

Definition at line 27 of file sx1280-hal.c.

◆ RADIO_nRESET_PIN

#define RADIO_nRESET_PIN   RADIO_nRESET_Pin

Definition at line 36 of file sx1280-hal.c.

◆ RADIO_nRESET_PORT

#define RADIO_nRESET_PORT   RADIO_nRESET_GPIO_Port

Definition at line 33 of file sx1280-hal.c.

◆ RADIO_NSS_PIN

#define RADIO_NSS_PIN   RADIO_NSS_Pin

Definition at line 42 of file sx1280-hal.c.

◆ RADIO_NSS_PORT

#define RADIO_NSS_PORT   RADIO_NSS_GPIO_Port

Definition at line 39 of file sx1280-hal.c.

Function Documentation

◆ SX1280HalGetDioStatus()

uint8_t SX1280HalGetDioStatus ( void )

Returns the status of DIOs pins.

Return values
dioStatusA byte where each bit represents a DIO state: [ DIOx | BUSY ]

Definition at line 452 of file sx1280-hal.c.

◆ SX1280HalInit()

void SX1280HalInit ( DioIrqHandler ** irqHandlers)

Definition at line 257 of file sx1280-hal.c.

◆ SX1280HalIoIrqInit()

void SX1280HalIoIrqInit ( DioIrqHandler ** irqHandlers)

Definition at line 269 of file sx1280-hal.c.

◆ SX1280HalReadBuffer()

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

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

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

Definition at line 435 of file sx1280-hal.c.

◆ SX1280HalReadCommand()

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

Send a command that read data from the radio.

Parameters
[in]opcodeOpcode of the command
[out]bufferBuffer holding data from the radio
[in]sizeSize of the buffer

Definition at line 350 of file sx1280-hal.c.

◆ SX1280HalReadRegister()

uint8_t SX1280HalReadRegister ( uint16_t address)

Read a single byte of data from the radio memory.

Parameters
[in]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

Definition at line 408 of file sx1280-hal.c.

◆ SX1280HalReadRegisters()

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

Read data from the radio memory.

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

Definition at line 390 of file sx1280-hal.c.

◆ SX1280HalReset()

void SX1280HalReset ( void )

Soft resets the radio.

Definition at line 274 of file sx1280-hal.c.

◆ SX1280HalSpiTxThenRx()

void SX1280HalSpiTxThenRx ( uint16_t tx_len,
uint8_t * rx_buffer,
uint16_t rx_len )

Definition at line 216 of file sx1280-hal.c.

◆ SX1280HalWaitOnBusy()

void SX1280HalWaitOnBusy ( void )

Used to block execution waiting for low state on radio busy pin. Essentially used in SPI communications.

Definition at line 252 of file sx1280-hal.c.

◆ SX1280HalWakeup()

void SX1280HalWakeup ( void )

Wakes up the radio.

Definition at line 310 of file sx1280-hal.c.

◆ SX1280HalWriteBuffer()

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

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

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

Definition at line 417 of file sx1280-hal.c.

◆ SX1280HalWriteCommand()

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

Send a command that write data to the radio.

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

Definition at line 330 of file sx1280-hal.c.

◆ SX1280HalWriteRegister()

void SX1280HalWriteRegister ( uint16_t address,
uint8_t value )

Write a single byte of data to the radio memory.

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

Definition at line 385 of file sx1280-hal.c.

◆ SX1280HalWriteRegisters()

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

Write data to the radio memory.

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

Definition at line 366 of file sx1280-hal.c.

Variable Documentation

◆ Radio

const struct Radio_s Radio

Radio driver.

Radio driver structure initialization

Definition at line 60 of file sx1280-hal.c.

◆ RADIO_SPI_DMA_RX

DMA_HandleTypeDef RADIO_SPI_DMA_RX
extern

◆ RADIO_SPI_DMA_TX

DMA_HandleTypeDef RADIO_SPI_DMA_TX
extern

◆ RADIO_SPI_HANDLE

SPI_HandleTypeDef RADIO_SPI_HANDLE
extern