Skip to content

oblaser/rpihal

Repository files navigation

raspihal

A Raspberry Pi Hardware Abstraction Layer for C/C++ projects. It includes an emulator.

The system tests can also be considered as examples 😉

GPIO Module

The library automatically detects the Raspberry Pi Model.

CAUTION! Unexpected behaviour may be observed on alternate functions (see ANOM1).

Supported Models

2B and newer, except 5 and it's derivates. Compute Modules could not yet be tested.

Search for ADDHW comments in code to find sections which are crucial for implementation of more hardware support.

Portability

The main focus lies on Raspberry Pi OS, but it's attempted to make the code compatible to other distros.

In fact Raspberry Pi OS 32bit and Raspberry Pi OS 64bit are different distros: Raspbian and a Debian arm64 port. See this article on Tom's Hardware for further information.

Build

See build/readme.md for the different build methods.

Build Configuration

CMake

  • RPIHAL_CMAKE_CONFIG_EMU only used in librpihal.a/CMakeLists.txt (has to be set to 1 before the add_subdirectory() call in the parent CMakeLists if needed)

Definitions on Compiler Level

  • RPIHAL_EMU has to be defined on compiler level for the linking code (most likely your application) and rpihal. If using librpihal.a/CMakeLists.txt, it has to be added before the add_subdirectory() call in the parent CMakeLists.

  • RPIHAL_CONFIG_LOGLEVEL

    • 0 OFF, no logging from rpihal
    • 1 ERROR
    • 2 WARNING
    • 3 INFO
    • 4 DEBUG