Multi-MCU Peripherals Interface

๐ฏ Universal Hardware Interface for Multi-MCU Development
A professional hardware abstraction layer enabling seamless MCU portability through unified peripheral APIs - designed for the HardFOC board ecosystem
๐ฏ Overview
๐ ๐๐ Live Complete Documentation - Interactive guides, examples, and step-by-step tutorials
This Internal Interface Wrap (IID) provides a unified interface for common MCU peripherals, enabling seamless portability between different microcontroller platforms. Originally designed for the HardFOC board which needs to support multiple MCU types, this abstraction layer allows developers to write hardware-agnostic code while maintaining optimal performance.
๐ Core Benefits
- ๐ MCU Portability - Write once, run on multiple MCU platforms
- ๐ฏ Unified APIs - Consistent interface across all peripheral types
- โก Performance - Zero-cost abstractions with compile-time optimization
- ๐ก๏ธ Type Safety - Strong typing with project-specific type system
- ๐ Extensible - Easy to add new MCUs and peripheral drivers
- ๐ Complete Coverage - 14+ peripheral interfaces for comprehensive hardware control
๐จ Design Philosophy
BaseGpio* led = GpioFactory::Create(GPIO_PIN_2, GPIO_OUTPUT);
led->SetHigh();
Unified GPIO base class for all digital GPIO implementations.
Definition BaseGpio.h:294
๐ Peripheral Interfaces
๐ ๐๐ Live Complete Documentation - Interactive guides, examples, and step-by-step tutorials
Core Peripherals
| Interface | Purpose | Key Features |
|------------—|----------—|---------------—|
| BaseGpio | Digital I/O control | Input/output, interrupts, pull-up/down |
| BaseAdc | Analog measurement | Multi-channel, calibration, DMA support |
| BasePwm | Motor/servo control | Frequency control, duty cycle, phase alignment |
| BaseUart | Serial communication | Async I/O, flow control, custom baud rates |
Communication Buses
| Interface | Purpose | Key Features |
|------------—|----------—|---------------—|
| BaseI2c | Sensor communication | Master/slave, clock stretching, error recovery |
| BaseSpi | High-speed data | Full/half duplex, DMA, chip select management |
| BaseCan | Automotive/industrial | Message filtering, error handling, bus monitoring |
Wireless Connectivity
| Interface | Purpose | Key Features |
|------------—|----------—|---------------—|
| BaseWifi | Network connectivity | STA/AP modes, WPA3 security, power management |
| BaseBluetooth | Short-range wireless | Classic/BLE, pairing, service discovery |
System Services
| Interface | Purpose | Key Features |
|------------—|----------—|---------------—|
| BaseNvs | Configuration storage | Key-value pairs, encryption, wear leveling |
| BaseLogger | Debug/monitoring | Multiple levels, async logging, filtering |
| BaseTemperature | Thermal monitoring | Internal/external sensors, calibration |
| BasePeriodicTimer | Task scheduling | Precise timing, ISR-safe callbacks |
| BasePio | Advanced GPIO | State machines, DMA, complex protocols |
๐ Quick Start
1. Clone Repository
git clone <repository-url>
cd hf-internal-interface-wrap
2. Setup Development Environment
## For ESP32 development
cd examples/esp32
./scripts/setup_repo.sh
3. Build Example
## Build GPIO test for ESP32
./scripts/build_app.sh gpio_test Release esp32
4. Flash and Monitor
## Flash to connected ESP32
./scripts/flash_app.sh gpio_test Release flash
## Monitor serial output
./scripts/flash_app.sh gpio_test Release monitor
5. Basic Usage
void setup() {
while(true) {
led->SetHigh();
vTaskDelay(pdMS_TO_TICKS(500));
led->SetLow();
vTaskDelay(pdMS_TO_TICKS(500));
}
}
Unified GPIO base class for all digital GPIO implementations.
Advanced MCU-specific implementation of the unified BaseGpio class with ESP32C6/ESP-IDF v5....
Advanced MCU-specific implementation of unified BaseGpio with ESP32C6/ESP-IDF v5.5+ features.
Definition EspGpio.h:65
๐ง Building
Build System Features
- Multi-MCU Support - Single build system for all platforms
- Automated Testing - Comprehensive test suites
- CI/CD Integration - Automated builds and validation
Build Commands
## Build specific application
./scripts/build_app.sh <app_name> <build_type> <target>
## Examples:
./scripts/build_app.sh gpio_test Debug esp32
./scripts/build_app.sh pwm_test Release esp32c6
./scripts/build_app.sh uart_test Debug esp32s3
yaml
Configuration
Applications are configured in examples/esp32/app_config.yml:
applications:
gpio_test:
source_file: "GpioComprehensiveTest.cpp"
description: "GPIO interface testing"
enabled: true
pwm_test:
source_file: "PwmComprehensiveTest.cpp"
description: "PWM interface testing"
enabled: true
๐ค Contributing
Development Workflow
- Fork the repository
- Create feature branch (
feature/new-mcu-support)
- Implement following coding standards
- Test with existing applications
- Document your changes
- Submit pull request
Adding New Peripherals
- Create base interface in
inc/base/BaseYourPeripheral.h
- Implement for ESP32 in
inc/mcu/esp32/EspYourPeripheral.h
- Add comprehensive tests in
examples/esp32/main/
- Update documentation
Coding Standards
- Functions: CamelCase (
SetDutyCycle, ReadValue)
- Types: snake_case with
*t suffix (hf_gpio_state_t)
- Enums: snake_case enum class (
hf_adc_err_t)
- Logging: Use
Logger::GetInstance() for all output
๐ Quick Links
Documentation
Development
- ๐ Examples - Test applications and usage examples
- ๐งช Test Documentation - Comprehensive test documentation
- ๐ง Scripts - Build, flash, and development tools
- ๐ Configuration - Application and build settings
Community
- ๐ค Contributing - Please refer to the HardFOC community for contribution guidelines