# RadioLib: RadioLibHal Class Reference

RadioLibHal Class Referenceabstract

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 (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

  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.

## 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

  interruptNum | Interrupt number to attach to (platform-specific).
  interruptCb | Interrupt service routine to execute.
  mode | Rising/falling mode (platform-specific).

## delay()

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

pure virtual

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

Parameters

  ms | Number of milliseconds to wait.

## delayMicroseconds()

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

pure virtual

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

Parameters

  us | Number of microseconds to wait.

## 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

  interruptNum | Interrupt number to detach from (platform-specific).

## digitalRead()

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

pure virtual

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

Parameters

  pin | Pin to be changed (platform-specific).

Returns
  Value read on the pin (platform-specific).

## 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

  pin | Pin to be changed (platform-specific).
  value | Value to set (platform-specific).

## 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.

## 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.

## noTone()

void RadioLibHal::noTone | ( | uint32_t | pin | ) |

virtual

Method to stop producing a tone.

Parameters

  pin | Pin which is currently producing the tone.

## 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

  pin | Pin to be changed (platform-specific).
  mode | Mode to be set (platform-specific).

## pinToInterrupt()

uint32_t RadioLibHal::pinToInterrupt | ( | uint32_t | pin | ) |

virtual

Function to convert from pin number to interrupt number.

Parameters

  pin | Pin 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

  pin | Pin to measure on (platform-specific).
  state | Pin level to monitor (platform-specific).
  timeout | Timeout in microseconds.

Returns
  Pulse length in microseconds, or 0 if the pulse did not start before timeout.

## spiTransfer()

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

pure virtual

Method to transfer buffer over SPI.

Parameters

  out | Buffer to send.
  len | Number of data to send or receive.
  in | Buffer to save received data into.

## 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

  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.

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

- src/Hal.h
- src/Hal.cpp