|
caffeine-hal 0.6.6
A Header-Defined Interface c library, it provides the hal layer for the Caffeine framework
|
A modern, strictly C11-compliant, header-only Hardware Abstraction Layer (HAL) for embedded systems.
Copyright (c) 2026 Hisham Moussa Daou https://whileone.me
Caffeine-HAL provides a polymorphic, Virtual Method Table (VMT) based interface for microcontrollers (primarily ARM Cortex-M). It is designed to be lightweight, thread-safe, and highly portable by decoupling the generic peripheral logic from vendor-specific board configurations.
INTERFACE library for easy integration.ci-all-sources preset for global formatting and documentation, ensuring every peripheral interface is consistently validated.caffeine::hal-mock STATIC library for native host testing of upper layers (SAL, Apps) without hardware dependencies. Automatically enabled via the global CFN_BUILD_TESTS flag.cfn_hal_base.h), ensuring a consistent lifecycle.CFN_HAL_WITH_LOCK for clean multi-threaded RTOS environments.clang-format, clang-tidy, and cppcheck (Allman style).You can easily integrate Caffeine-HAL into your project using modern CMake.
Option A: FetchContent (Recommended) Download and link the library automatically during the CMake configure step.
Option B: Native Testing with Mocks Enable the global test flag to automatically expose the mock library.
The project includes built-in targets for maintaining code quality:
cmake --build build --target caffeine-hal-formatcmake --build build --target caffeine-hal-analyzecmake --build build --target caffeine-hal-test (Requires -D CFN_BUILD_TESTS=ON)Use the framework's centralized scripts for orchestration:
caffeine-build/: Submodule containing centralized build presets, toolchains, scripts, and hardware target definitions.include/: Foundational hardware abstraction headers and polymorphic VMT definitions.src/mock/: Stubs and bridges for the caffeine::hal-mock library.tests/: GTest suite for validating framework logic on host.The API reference for this repository is generated automatically via Doxygen and hosted on GitHub Pages.
📚 View the Caffeine-HAL API Documentation
caffeine-hal):** This repository. Definitions of the HAL and Virtual Method Tables (VMTs).caffeine-hal-ports):** Concrete implementations for specific vendors. Encapsulates low-level hardware definitions into target scripts (e.g., stm32f417vgtx.cmake).caffeine-sal):** Hardware-agnostic device drivers and connectivity abstractions.caffeine-app-mvp):** Top-level business logic utilizing the framework.While this library is no Mondrian, it deals with a different form of abstraction art. Hardware abstraction is a craft of its own—one that keeps your application code portable and your debugging sessions short.
Whether Caffeine is fueling an elegant embedded project or just helping you wake up your hardware, you can contribute in the following ways:
If my projects helped you, feel free to buy me a brew. Or if it caused you an extra debugging session, open a PR!
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.