Open RTS
Full implementation of the Somfy RTS protocol
Loading...
Searching...
No Matches
OOK Radio Library

A collection of userland SPI drivers for "OOK" radio modules. More...

Data Structures

struct  rfm69
 An SPI-attached SX1231 or RFM69 radio module. More...
 
struct  sx1278
 An SPI-attached SX1278 or RFM96 radio module. More...
 
struct  spi_module
 Hardware abstraction layer for userland SPI drivers. More...
 

Enumerations

enum  {
  OOKRADIO_ERR_NONE = 0 ,
  OOKRADIO_ERR_INVALID_HANDLE = -1 ,
  OOKRADIO_ERR_INVALID_SPI = -2 ,
  OOKRADIO_ERR_INVALID_MODULE = -3 ,
  OOKRADIO_ERR_SPI_INIT_FAILED = -4 ,
  OOKRADIO_ERR_SPI_TRANSFER_FAILED = -5
}
 

Functions

int rfm69_init (struct rfm69 *radio, struct spi_module *spi)
 Initialize an SPI-attached RFM69 radio module.
 
void sx1278_init (struct sx1278 *radio, struct spi_module *spi)
 Initialize an SPI-attached SX1278/RFM96 radio module.
 
uint8_t spi_read (struct spi_module *spi, uint8_t reg)
 Read a byte from the spi device at the specified register address.
 
void spi_write (struct spi_module *spi, uint8_t reg, uint8_t val)
 Write a byte to the spi device at the specified register address.
 
void spi_write_masked (struct spi_module *spi, uint8_t reg, uint8_t mask, uint8_t val)
 Write some bits of val to the spi device at the specified register address, using a bitmask.
 
int spi_module_init_arduino (struct spi_module *spi_module, SPIClass *spi_device)
 Initialize an spi_module struct using Arduino's SPI interface.
 
int spi_module_init_espidf (struct spi_module *spi_module, spi_host_device_t host_device)
 Initialize an spi_module struct using the ESP-IDF SPI interface.
 
int spi_module_init_linux (struct spi_module *spi_module, const char *device)
 Initialize an spi_module struct using Linux spidev.
 

Detailed Description

A collection of userland SPI drivers for "OOK" radio modules.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OOKRADIO_ERR_NONE 

All good.

OOKRADIO_ERR_INVALID_HANDLE 

The radio pointer is NULL.

OOKRADIO_ERR_INVALID_SPI 

The spi_module pointer is NULL.

OOKRADIO_ERR_INVALID_MODULE 

The attached SPI module could not be identified.

OOKRADIO_ERR_SPI_INIT_FAILED 

SPI init failed.

OOKRADIO_ERR_SPI_TRANSFER_FAILED 

SPI transfer failed.

Function Documentation

◆ rfm69_init()

int rfm69_init ( struct rfm69 radio,
struct spi_module spi 
)
related

Initialize an SPI-attached RFM69 radio module.

Parameters
radiothe rfm69 struct to initialize
spithe spi_module we are connecting through
Returns
OOKRADIO_ERR_NONE if initialized successfully

◆ sx1278_init()

void sx1278_init ( struct sx1278 radio,
struct spi_module spi 
)
related

Initialize an SPI-attached SX1278/RFM96 radio module.

Parameters
radiothe sx1278 struct to initialize
spithe spi_module we are connecting through
Returns
OOKRADIO_ERR_NONE if initialized successfully

◆ spi_read()

uint8_t spi_read ( struct spi_module spi,
uint8_t  reg 
)
related

Read a byte from the spi device at the specified register address.

Parameters
spithe spi_module to read from
regthe register address to read from
Returns
the value returned from the device

◆ spi_write()

void spi_write ( struct spi_module spi,
uint8_t  reg,
uint8_t  val 
)
related

Write a byte to the spi device at the specified register address.

Parameters
spithe spi_module to write to
regthe register address to write to

◆ spi_write_masked()

void spi_write_masked ( struct spi_module spi,
uint8_t  reg,
uint8_t  mask,
uint8_t  val 
)
related

Write some bits of val to the spi device at the specified register address, using a bitmask.

Parameters
spithe spi_module to write to
regthe register address to write to

◆ spi_module_init_arduino()

int spi_module_init_arduino ( struct spi_module spi_module,
SPIClass *  spi_device 
)
related

Initialize an spi_module struct using Arduino's SPI interface.

Note
Only available on Arduino builds
Parameters
spi_modulethe spi_module struct to initialize
spi_devicea pointer to the Arduino SPI device to use, e.g. &SPI
Returns
  • OOKRADIO_ERR_NONE if successful
  • OOKRADIO_ERR_SPI_INIT_FAILED if unsuccessful

◆ spi_module_init_espidf()

int spi_module_init_espidf ( struct spi_module spi_module,
spi_host_device_t  host_device 
)
related

Initialize an spi_module struct using the ESP-IDF SPI interface.

Note
Only available on ESP-IDF (ESP32, etc) builds
Parameters
spi_modulethe spi_module struct to initialize
host_devicethe SPI host device to use, e.g. HSPI_HOST
Returns
  • OOKRADIO_ERR_NONE if successful
  • OOKRADIO_ERR_SPI_INIT_FAILED if unsuccessful

◆ spi_module_init_linux()

int spi_module_init_linux ( struct spi_module spi_module,
const char *  device 
)
related

Initialize an spi_module struct using Linux spidev.

Note
Only available on Linux builds, spidev must be enabled
Parameters
spi_modulethe spi_module struct to initialize
devicethe spi device to use, e.g. /dev/spidev0.1
Returns
  • OOKRADIO_ERR_NONE if successful
  • OOKRADIO_ERR_SPI_INIT_FAILED if unsuccessful