RadioLib
Universal wireless communication library for Arduino
|
Hardware abstraction library base interface. More...
#include <Hal.h>
Public Member Functions | |
RadioLibHal (const uint32_t input, const uint32_t output, const uint32_t low, const uint32_t high, const uint32_t rising, const uint32_t falling) | |
Default constructor. More... | |
virtual void | pinMode (uint32_t pin, uint32_t mode)=0 |
GPIO pin mode (input/output/...) configuration method. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual void | digitalWrite (uint32_t pin, uint32_t value)=0 |
Digital write method. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual uint32_t | digitalRead (uint32_t pin)=0 |
Digital read method. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual void | attachInterrupt (uint32_t interruptNum, void(*interruptCb)(void), uint32_t mode)=0 |
Method to attach function to an external interrupt. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual void | detachInterrupt (uint32_t interruptNum)=0 |
Method to detach function from an external interrupt. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual void | delay (unsigned long ms)=0 |
Blocking wait function. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual void | delayMicroseconds (unsigned long us)=0 |
Blocking microsecond wait function. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual unsigned long | millis ()=0 |
Get number of milliseconds since start. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual unsigned long | micros ()=0 |
Get number of microseconds since start. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual long | pulseIn (uint32_t pin, uint32_t state, unsigned long timeout)=0 |
Measure the length of incoming digital pulse in microseconds. Must be implemented by the platform-specific hardware abstraction! More... | |
virtual void | spiBegin ()=0 |
SPI initialization method. | |
virtual void | spiBeginTransaction ()=0 |
Method to start SPI transaction. | |
virtual void | spiTransfer (uint8_t *out, size_t len, uint8_t *in)=0 |
Method to transfer buffer over SPI. More... | |
virtual void | spiEndTransaction ()=0 |
Method to end SPI transaction. | |
virtual void | spiEnd ()=0 |
SPI termination method. | |
virtual void | init () |
Module initialization method. This will be called by all radio modules at the beginning of startup. Can be used to e.g., initialize SPI interface. | |
virtual void | term () |
Module termination method. This will be called by all radio modules when the destructor is called. Can be used to e.g., stop SPI interface. | |
virtual void | tone (uint32_t pin, unsigned int frequency, unsigned long duration=0) |
Method to produce a square-wave with 50% duty cycle ("tone") of a given frequency at some pin. More... | |
virtual void | noTone (uint32_t pin) |
Method to stop producing a tone. More... | |
virtual void | yield () |
Yield method, called from long loops in multi-threaded environment (to prevent blocking other threads). | |
virtual uint32_t | pinToInterrupt (uint32_t pin) |
Function to convert from pin number to interrupt number. More... | |
virtual void | readPersistentStorage (uint32_t addr, uint8_t *buff, size_t len) |
Method to read from persistent storage (e.g. EEPROM). More... | |
virtual void | writePersistentStorage (uint32_t addr, uint8_t *buff, size_t len) |
Method to write to persistent storage (e.g. EEPROM). More... | |
void | wipePersistentStorage () |
Method to wipe the persistent storage by writing to 0. Will write at most RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE bytes. | |
uint32_t | getPersistentAddr (uint32_t id) |
Method to convert from persistent parameter ID to its physical address. More... | |
template<typename T > | |
void | setPersistentParameter (uint32_t id, T val, uint32_t offset=0) |
Method to set arbitrary parameter to persistent storage. This method DOES NOT perform any endianness conversion, so the value will be stored in the system endian! More... | |
template<typename T > | |
T | getPersistentParameter (uint32_t id) |
Method to get arbitrary parameter from persistent storage. This method DOES NOT perform any endianness conversion, so the value will be retrieved in the system endian! More... | |
Public Attributes | |
const uint32_t | GpioModeInput |
Value to be used as the "input" GPIO direction. | |
const uint32_t | GpioModeOutput |
Value to be used as the "output" GPIO direction. | |
const uint32_t | GpioLevelLow |
Value to be used as the "low" GPIO level. | |
const uint32_t | GpioLevelHigh |
Value to be used as the "high" GPIO level. | |
const uint32_t | GpioInterruptRising |
Value to be used as the "rising" GPIO level change direction. | |
const uint32_t | GpioInterruptFalling |
Value to be used as the "falling" GPIO level change direction. | |
Hardware abstraction library base interface.
RadioLibHal::RadioLibHal | ( | const uint32_t | input, |
const uint32_t | output, | ||
const uint32_t | low, | ||
const uint32_t | high, | ||
const uint32_t | rising, | ||
const uint32_t | falling | ||
) |
Default constructor.
input | Value to be used as the "input" GPIO direction. |
output | Value to be used as the "output" GPIO direction. |
low | Value to be used as the "low" GPIO level. |
high | Value to be used as the "high" GPIO level. |
rising | Value to be used as the "rising" GPIO level change direction. |
falling | Value to be used as the "falling" GPIO level change direction. |
|
pure virtual |
Method to attach function to an external interrupt. Must be implemented by the platform-specific hardware abstraction!
interruptNum | Interrupt number to attach to (platform-specific). |
interruptCb | Interrupt service routine to execute. |
mode | Rising/falling mode (platform-specific). |
|
pure virtual |
Blocking wait function. Must be implemented by the platform-specific hardware abstraction!
ms | Number of milliseconds to wait. |
|
pure virtual |
Blocking microsecond wait function. Must be implemented by the platform-specific hardware abstraction!
us | Number of microseconds to wait. |
|
pure virtual |
Method to detach function from an external interrupt. Must be implemented by the platform-specific hardware abstraction!
interruptNum | Interrupt number to detach from (platform-specific). |
|
pure virtual |
Digital read method. Must be implemented by the platform-specific hardware abstraction!
pin | Pin to be changed (platform-specific). |
|
pure virtual |
Digital write method. Must be implemented by the platform-specific hardware abstraction!
pin | Pin to be changed (platform-specific). |
value | Value to set (platform-specific). |
uint32_t RadioLibHal::getPersistentAddr | ( | uint32_t | id | ) |
Method to convert from persistent parameter ID to its physical address.
id | Parameter ID. |
template uint32_t RadioLibHal::getPersistentParameter | ( | uint32_t | id | ) |
Method to get arbitrary parameter from persistent storage. This method DOES NOT perform any endianness conversion, so the value will be retrieved in the system endian!
id | Parameter ID to load from. |
|
pure virtual |
Get number of microseconds since start. Must be implemented by the platform-specific hardware abstraction!
|
pure virtual |
Get number of milliseconds since start. Must be implemented by the platform-specific hardware abstraction!
|
virtual |
Method to stop producing a tone.
pin | Pin which is currently producing the tone. |
|
pure virtual |
GPIO pin mode (input/output/...) configuration method. Must be implemented by the platform-specific hardware abstraction!
pin | Pin to be changed (platform-specific). |
mode | Mode to be set (platform-specific). |
|
virtual |
Function to convert from pin number to interrupt number.
pin | Pin to convert from. |
|
pure virtual |
Measure the length of incoming digital pulse in microseconds. Must be implemented by the platform-specific hardware abstraction!
pin | Pin to measure on (platform-specific). |
state | Pin level to monitor (platform-specific). |
timeout | Timeout in microseconds. |
|
virtual |
Method to read from persistent storage (e.g. EEPROM).
addr | Address to start reading at. |
buff | Buffer to read into. |
len | Number of bytes to read. |
template void RadioLibHal::setPersistentParameter | ( | uint32_t | id, |
T | val, | ||
uint32_t | offset = 0 |
||
) |
Method to set arbitrary parameter to persistent storage. This method DOES NOT perform any endianness conversion, so the value will be stored in the system endian!
id | Parameter ID to save at. |
val | Value to set. |
offset | An additional offset added to the address. |
|
pure virtual |
Method to transfer buffer over SPI.
out | Buffer to send. |
len | Number of data to send or receive. |
in | Buffer to save received data into. |
|
virtual |
Method to produce a square-wave with 50% duty cycle ("tone") of a given frequency at some pin.
pin | Pin to be used as the output. |
frequency | Frequency of the square wave. |
duration | Duration of the tone in ms. When set to 0, the tone will be infinite. |
|
virtual |
Method to write to persistent storage (e.g. EEPROM).
addr | Address to start writing to. |
buff | Buffer to write. |
len | Number of bytes to write. |