HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
StmI2c.h File Reference

STM32 I2C Bus+Device wrapper — wraps STM32 HAL I2C via CubeMX handle. More...

#include "BaseI2c.h"
#include "StmTypes.h"
#include <vector>
#include <memory>
Include dependency graph for StmI2c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  StmI2cDevice
 STM32 I2C device — inherits BaseI2c, delegates I/O to parent bus HAL handle. More...
 
class  StmI2cBus
 STM32 I2C bus — manages the HAL handle and device collection. More...
 

Detailed Description

STM32 I2C Bus+Device wrapper — wraps STM32 HAL I2C via CubeMX handle.

Bus/Device architecture matching the ESP32 pattern:

Usage

extern I2C_HandleTypeDef hi2c1;
hf_i2c_bus_config_t bus_cfg(&hi2c1);
StmI2cBus i2cBus(bus_cfg);
i2cBus.Initialize();
dev_cfg.device_address = 0x68; // MPU6050
int idx = i2cBus.CreateDevice(dev_cfg);
BaseI2c* mpu = i2cBus.GetDevice(idx);
mpu->Initialize();
uint8_t who_am_i = 0;
mpu->ReadRegister(0x75, who_am_i);
Abstract base class for I2C device implementations.
Definition BaseI2c.h:196
virtual bool Initialize() noexcept=0
Initialize the I2C bus.
virtual bool ReadRegister(hf_u8_t reg_addr, hf_u8_t &data) noexcept
Read from a register on the I2C device.
Definition BaseI2c.h:375
STM32 I2C bus — manages the HAL handle and device collection.
Definition StmI2c.h:87
Platform-agnostic I2C bus configuration for STM32. Users pass their CubeMX-generated I2C_HandleTypeDe...
Definition StmTypes.h:249
I2C device configuration structure.
Definition EspTypes_I2C.h:225
uint16_t device_address
7-bit or 10-bit device address
Definition EspTypes_I2C.h:226
Author
HardFOC
Date
2025