Shared platform layer for HardFOC boards β handlers, RTOS utilities, driver integration, and CANopen for motor control systems

π Table of Contents
- Overview
- Features
- Architecture
- Quick Start
- Handlers
- Utilities
- Repository Structure
- Documentation
- Contributing
- License
π¦ Overview
π ππ Live Complete Documentation β Architecture guides, per-handler API reference, and testing instructions
hf-core is the shared platform layer for all HardFOC boards. It provides the handler layer, RTOS utilities, and driver integration that form the backbone of the HardFOC motor control system.
hf-core is the bridge layer between hardware-agnostic base interfaces (BaseI2c, BaseSpi, BaseGpio, BaseAdc, BaseTemperature) and CRTP-templated device drivers (hf-tmc9660-driver, hf-bno08x-driver, hf-as5047u-driver, etc.). No board-specific configuration lives here β board HALs (e.g. hf-hal-vortex-v1) depend on this repo and add managers, API, and pin mapping.
β¨ Features
- β
11 Device Handlers β AS5047U, BNO08x, PCA9685, PCAL95555, NTC, TMC9660, TMC5160, TLE92466ED, MAX22200, WS2812, Logger
- β
30+ General Utilities β Buffers, filters, timers, CRC, interpolation, linked lists, flag sets, physical units
- β
Full RTOS Abstraction β Mutex, semaphore, queue, event flags, threads, timers
- β
CANopen Utilities β CAN frame, SDO protocol, NMT commands
- β
ESP32 Test Suite β 15 test applications covering every handler, utility, and integration scenario
- β
8 CI Pipelines β Build, lint, analysis, documentation, release
- β
Thread-Safe β All handlers use
RtosMutex for safe concurrent access
- β
Modern C++20 β Type-safe APIs with CRTP-based design and zero-overhead abstractions
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Board HAL (Vortex) β Managers + API
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
β hf-core (this repo) β
β ββββββββββββ ββββββββββββββββ βββββββββββββ β
β β Handlers β β hf-core-utilsβ β Logger β β
β β (adapt) β β (general, β β(singleton)β β
β β β β rtos, can) β β β β
β ββββββ¬ββββββ ββββββββββββββββ βββββββββββββ β
β β β
β ββββββΌβββββββββββββββββββββββββββββββββββββββ β
β β hf-core-drivers (submodule) β β
β β BaseI2c, BaseSpi, BaseGpio, BaseAdc β β
β β AS5047U, BNO08x, PCA9685, TMC9660 ... β β
β βββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
β MCU Platform (ESP32, etc.) β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Handlers own their driver instances and translate base-interface calls into high-level operations. They never expose the raw driver β all access goes through handler methods.
π Quick Start
Clone
git clone --recurse-submodules https://github.com/hardfoc/hf-core.git
Or after a shallow clone:
git submodule update --init --recursive
Build and Flash a Test
cd examples/esp32/scripts
# Build a utility test (no hardware needed)
./build_app.sh general_utils_test Debug
# Flash and monitor
cd .. && idf.py -p /dev/ttyUSB0 flash monitor
Build All CI-Enabled Tests
Use the CI pipeline or iterate over app_config.yml entries:
./build_app.sh list # See all available apps
π Handlers
| Handler | Device | Bus | Key Capabilities |
As5047uHandler | AS5047U | SPI | Angle, velocity, DAEC, diagnostics, zero-position |
Bno08xHandler | BNO08x | I2C | Sensor enable/disable, data read, freshness gating |
Pca9685Handler | PCA9685 | I2C | PWM duty/frequency, phase offset, sleep/wake |
Pcal95555Handler | PCAL95555 | I2C | GPIO read/write, toggle, batch, interrupt drain |
NtcTemperatureHandler | NTC | ADC | Temperature, calibration, EMA filter, thresholds |
Tmc9660Handler | TMC9660 | SPI/UART | Motor control, telemetry, GPIO/ADC/temp wrappers |
Tmc5160Handler | TMC5160 | SPI/UART | Stepper motor, ramp generator, StallGuard, visitDriver |
Tle92466edHandler | TLE92466ED | SPI | 6-ch solenoid driver, PWM, diagnostics, watchdog |
Max22200Handler | MAX22200 | SPI | 8-ch solenoid/motor, CDR/VDR, HIT/HOLD, DPM |
Ws2812Handler | WS2812 | RMT | Addressable LED strip, pixel control, animations |
Logger | β | β | Singleton, log levels, per-tag filter, formatted output |
π§ Utilities
| Library | Contents |
hf-utils-general | CircularBuffer, RingBuffer, AveragingFilter, CRC, ActionTimer, IntervalAction, SoftwareVersion, LinearInterpolation, SimpleLinkedList, FlagSet, PhysicalUnit, and more |
hf-utils-rtos-wrap | RtosMutex, MutexLockGuard, PeriodicTimer, BaseThread, OsQueue, OsEventFlags, OsSemaphore, os_delay_msec |
hf-utils-canopen | CanFrame, SDO helpers, NMT commands |
π Repository Structure
hf-core/
βββ handlers/ # Device handler implementations
β βββ as5047u/ # Magnetic encoder (SPI)
β βββ bno08x/ # 9-axis IMU (I2C)
β βββ common/ # Shared handler utilities (HandlerCommon.h)
β βββ logger/ # Singleton logging
β βββ max22200/ # 8-ch solenoid/motor driver (SPI)
β βββ ntc/ # NTC thermistor (ADC)
β βββ pca9685/ # 16-ch PWM controller (I2C)
β βββ pcal95555/ # 16-bit GPIO expander (I2C)
β βββ tle92466ed/ # 6-ch solenoid driver (SPI)
β βββ tmc5160/ # Stepper motor driver (SPI/UART)
β βββ tmc9660/ # Motor controller (SPI/UART)
β βββ ws2812/ # Addressable LED strip (RMT)
βββ hf-core-drivers/ # [submodule] Base interfaces + external drivers
βββ hf-core-utils/ # [submodule] General, RTOS, CANopen utilities
βββ examples/
β βββ esp32/ # ESP-IDF test applications
β βββ app_config.yml # Test app registry (15 apps)
β βββ main/
β β βββ handler_tests/ # 10 handler test apps
β β βββ utils_tests/ # 4 utility test apps
β β βββ integration_tests/ # 1 integration test
β βββ components/
β βββ hf_core/ # ESP-IDF component wrapper
βββ .github/workflows/ # 8 CI pipelines
βββ _config/ # clang-format, clang-tidy, Jekyll, Doxygen, linters
βββ docs/ # Jekyll documentation site
βββ README.md
π Documentation
Full documentation is available at the GitHub Pages site:
- Architecture β Layered design, handler pattern, ownership
- Folder Structure β Complete tree with descriptions
- Handler Reference β Per-handler API documentation
- Utilities Reference β General, RTOS, CANopen utilities
- Testing Guide β How to build and run tests
- CI Pipelines β Workflow descriptions
π€ Contributing
- Create a feature branch from
develop
- Follow
.clang-format and .clang-tidy (configs in _config/)
- Add or update tests for any handler/utility changes
- Ensure all CI checks pass
- Open a pull request targeting
develop
π License
This project is licensed under the GNU General Public License v3.0. See the GPL v3 license for details. Individual submodules may carry their own licenses β see per-submodule LICENSE files.