HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
StmI2cBus Class Reference

STM32 I2C bus — manages the HAL handle and device collection. More...

#include <StmI2c.h>

Collaboration diagram for StmI2cBus:
[legend]

Public Member Functions

 StmI2cBus (const hf_i2c_bus_config_t &config) noexcept
 
 StmI2cBus (I2C_HandleTypeDef *hal_handle, hf_u32_t timeout_ms=1000) noexcept
 Convenience: construct directly from HAL handle.
 
 ~StmI2cBus () noexcept
 
bool Initialize () noexcept
 
bool IsInitialized () const noexcept
 
bool Deinitialize () noexcept
 
int CreateDevice (const hf_i2c_device_config_t &device_config) noexcept
 Create a device on this bus and return its index.
 
BaseI2cGetDevice (int device_index) noexcept
 Get device by index (returns nullptr if invalid)
 
const BaseI2cGetDevice (int device_index) const noexcept
 
std::size_t GetDeviceCount () const noexcept
 Get number of devices on this bus.
 
bool RemoveDevice (int device_index) noexcept
 Remove a device by index.
 
const hf_i2c_bus_config_tGetConfig () const noexcept
 Get the bus configuration.
 
I2C_HandleTypeDef * GetHalHandle () const noexcept
 Get the STM32 HAL I2C handle.
 

Private Attributes

hf_i2c_bus_config_t config_
 
bool initialized_ {false}
 
std::vector< std::unique_ptr< StmI2cDevice > > devices_
 

Detailed Description

STM32 I2C bus — manages the HAL handle and device collection.

One bus instance per I2C peripheral (I2C1, I2C2, etc.). Devices are created via CreateDevice() and accessed via GetDevice().

Constructor & Destructor Documentation

◆ StmI2cBus() [1/2]

StmI2cBus::StmI2cBus ( const hf_i2c_bus_config_t & config)
explicitnoexcept

◆ StmI2cBus() [2/2]

StmI2cBus::StmI2cBus ( I2C_HandleTypeDef * hal_handle,
hf_u32_t timeout_ms = 1000 )
explicitnoexcept

Convenience: construct directly from HAL handle.

◆ ~StmI2cBus()

StmI2cBus::~StmI2cBus ( )
noexcept

Member Function Documentation

◆ CreateDevice()

int StmI2cBus::CreateDevice ( const hf_i2c_device_config_t & device_config)
noexcept

Create a device on this bus and return its index.

◆ Deinitialize()

bool StmI2cBus::Deinitialize ( )
noexcept

◆ GetConfig()

const hf_i2c_bus_config_t & StmI2cBus::GetConfig ( ) const
noexcept

Get the bus configuration.

◆ GetDevice() [1/2]

const BaseI2c * StmI2cBus::GetDevice ( int device_index) const
noexcept

◆ GetDevice() [2/2]

BaseI2c * StmI2cBus::GetDevice ( int device_index)
noexcept

Get device by index (returns nullptr if invalid)

◆ GetDeviceCount()

std::size_t StmI2cBus::GetDeviceCount ( ) const
noexcept

Get number of devices on this bus.

◆ GetHalHandle()

I2C_HandleTypeDef * StmI2cBus::GetHalHandle ( ) const
noexcept

Get the STM32 HAL I2C handle.

◆ Initialize()

bool StmI2cBus::Initialize ( )
noexcept

◆ IsInitialized()

bool StmI2cBus::IsInitialized ( ) const
noexcept

◆ RemoveDevice()

bool StmI2cBus::RemoveDevice ( int device_index)
noexcept

Remove a device by index.

Member Data Documentation

◆ config_

hf_i2c_bus_config_t StmI2cBus::config_
private

◆ devices_

std::vector<std::unique_ptr<StmI2cDevice> > StmI2cBus::devices_
private

◆ initialized_

bool StmI2cBus::initialized_ {false}
private

The documentation for this class was generated from the following files: