RadioLib
Universal wireless communication library for Arduino
RadioLibHal Class Referenceabstract

Hardware abstraction library base interface. More...

#include <Hal.h>

Inheritance diagram for RadioLibHal:
PiHal PicoHal

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 (RadioLibTime_t ms)=0
 Blocking wait function. Must be implemented by the platform-specific hardware abstraction! More...
 
virtual void delayMicroseconds (RadioLibTime_t us)=0
 Blocking microsecond wait function. Must be implemented by the platform-specific hardware abstraction! More...
 
virtual RadioLibTime_t millis ()=0
 Get number of milliseconds since start. Must be implemented by the platform-specific hardware abstraction! More...
 
virtual RadioLibTime_t 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, RadioLibTime_t 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, RadioLibTime_t 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...
 

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.
 

Detailed Description

Hardware abstraction library base interface.

Constructor & Destructor Documentation

◆ RadioLibHal()

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.

Parameters
inputValue to be used as the "input" GPIO direction.
outputValue to be used as the "output" GPIO direction.
lowValue to be used as the "low" GPIO level.
highValue to be used as the "high" GPIO level.
risingValue to be used as the "rising" GPIO level change direction.
fallingValue to be used as the "falling" GPIO level change direction.

Member Function Documentation

◆ attachInterrupt()

virtual void RadioLibHal::attachInterrupt ( uint32_t  interruptNum,
void(*)(void)  interruptCb,
uint32_t  mode 
)
pure virtual

Method to attach function to an external interrupt. Must be implemented by the platform-specific hardware abstraction!

Parameters
interruptNumInterrupt number to attach to (platform-specific).
interruptCbInterrupt service routine to execute.
modeRising/falling mode (platform-specific).

Implemented in PicoHal, and PiHal.

◆ delay()

virtual void RadioLibHal::delay ( RadioLibTime_t  ms)
pure virtual

Blocking wait function. Must be implemented by the platform-specific hardware abstraction!

Parameters
msNumber of milliseconds to wait.

Implemented in PicoHal, and PiHal.

◆ delayMicroseconds()

virtual void RadioLibHal::delayMicroseconds ( RadioLibTime_t  us)
pure virtual

Blocking microsecond wait function. Must be implemented by the platform-specific hardware abstraction!

Parameters
usNumber of microseconds to wait.

Implemented in PicoHal, and PiHal.

◆ detachInterrupt()

virtual void RadioLibHal::detachInterrupt ( uint32_t  interruptNum)
pure virtual

Method to detach function from an external interrupt. Must be implemented by the platform-specific hardware abstraction!

Parameters
interruptNumInterrupt number to detach from (platform-specific).

Implemented in PicoHal, and PiHal.

◆ digitalRead()

virtual uint32_t RadioLibHal::digitalRead ( uint32_t  pin)
pure virtual

Digital read method. Must be implemented by the platform-specific hardware abstraction!

Parameters
pinPin to be changed (platform-specific).
Returns
Value read on the pin (platform-specific).

Implemented in PicoHal, and PiHal.

◆ digitalWrite()

virtual void RadioLibHal::digitalWrite ( uint32_t  pin,
uint32_t  value 
)
pure virtual

Digital write method. Must be implemented by the platform-specific hardware abstraction!

Parameters
pinPin to be changed (platform-specific).
valueValue to set (platform-specific).

Implemented in PicoHal, and PiHal.

◆ micros()

virtual RadioLibTime_t RadioLibHal::micros ( )
pure virtual

Get number of microseconds since start. Must be implemented by the platform-specific hardware abstraction!

Returns
Number of microseconds since start.

Implemented in PicoHal, and PiHal.

◆ millis()

virtual RadioLibTime_t RadioLibHal::millis ( )
pure virtual

Get number of milliseconds since start. Must be implemented by the platform-specific hardware abstraction!

Returns
Number of milliseconds since start.

Implemented in PicoHal, and PiHal.

◆ noTone()

void RadioLibHal::noTone ( uint32_t  pin)
virtual

Method to stop producing a tone.

Parameters
pinPin which is currently producing the tone.

Reimplemented in PicoHal, and PiHal.

◆ pinMode()

virtual void RadioLibHal::pinMode ( uint32_t  pin,
uint32_t  mode 
)
pure virtual

GPIO pin mode (input/output/...) configuration method. Must be implemented by the platform-specific hardware abstraction!

Parameters
pinPin to be changed (platform-specific).
modeMode to be set (platform-specific).

Implemented in PicoHal, and PiHal.

◆ pinToInterrupt()

uint32_t RadioLibHal::pinToInterrupt ( uint32_t  pin)
virtual

Function to convert from pin number to interrupt number.

Parameters
pinPin to convert from.
Returns
The interrupt number of a given pin.

◆ pulseIn()

virtual long RadioLibHal::pulseIn ( uint32_t  pin,
uint32_t  state,
RadioLibTime_t  timeout 
)
pure virtual

Measure the length of incoming digital pulse in microseconds. Must be implemented by the platform-specific hardware abstraction!

Parameters
pinPin to measure on (platform-specific).
statePin level to monitor (platform-specific).
timeoutTimeout in microseconds.
Returns
Pulse length in microseconds, or 0 if the pulse did not start before timeout.

Implemented in PicoHal, and PiHal.

◆ spiTransfer()

virtual void RadioLibHal::spiTransfer ( uint8_t *  out,
size_t  len,
uint8_t *  in 
)
pure virtual

Method to transfer buffer over SPI.

Parameters
outBuffer to send.
lenNumber of data to send or receive.
inBuffer to save received data into.

Implemented in PicoHal, and PiHal.

◆ tone()

void RadioLibHal::tone ( uint32_t  pin,
unsigned int  frequency,
RadioLibTime_t  duration = 0 
)
virtual

Method to produce a square-wave with 50% duty cycle ("tone") of a given frequency at some pin.

Parameters
pinPin to be used as the output.
frequencyFrequency of the square wave.
durationDuration of the tone in ms. When set to 0, the tone will be infinite.

Reimplemented in PicoHal, and PiHal.


The documentation for this class was generated from the following files: