|
| virtual | ~BaseI2c () noexcept=default |
| | Virtual destructor ensures proper cleanup in derived classes.
|
| |
| | BaseI2c (const BaseI2c &)=delete |
| |
| BaseI2c & | operator= (const BaseI2c &)=delete |
| |
| | BaseI2c (BaseI2c &&)=delete |
| |
| BaseI2c & | operator= (BaseI2c &&)=delete |
| |
| bool | EnsureInitialized () noexcept |
| | Ensures that the I2C bus is initialized (lazy initialization).
|
| |
| bool | EnsureDeinitialized () noexcept |
| | Ensures that the I2C bus is deinitialized (lazy deinitialization).
|
| |
| bool | IsInitialized () const noexcept |
| | Checks if the bus is initialized.
|
| |
| virtual bool | Initialize () noexcept=0 |
| | Initialize the I2C bus.
|
| |
| virtual bool | Deinitialize () noexcept=0 |
| | Deinitialize the I2C bus.
|
| |
| virtual hf_i2c_err_t | Write (const hf_u8_t *data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept=0 |
| | Write data to the I2C device.
|
| |
| virtual hf_i2c_err_t | Read (hf_u8_t *data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept=0 |
| | Read data from the I2C device.
|
| |
| virtual hf_i2c_err_t | WriteRead (const hf_u8_t *tx_data, hf_u16_t tx_length, hf_u8_t *rx_data, hf_u16_t rx_length, hf_u32_t timeout_ms=0) noexcept=0 |
| | Write then read data from the I2C device.
|
| |
| virtual hf_u16_t | GetDeviceAddress () const noexcept=0 |
| | Get the device address for this I2C device.
|
| |
| virtual bool | Open () noexcept |
| | Open the I2C bus (alias for Initialize).
|
| |
| virtual bool | Close () noexcept |
| | Close the I2C bus (alias for Deinitialize).
|
| |
| virtual bool | IsDevicePresent () noexcept |
| | Check if this device is present on the bus.
|
| |
| virtual bool | ProbeDevice () noexcept |
| | Probe if this device is present on the bus (alias for IsDevicePresent).
|
| |
| virtual bool | WriteByte (hf_u8_t data) noexcept |
| | Write a single byte to the I2C device.
|
| |
| virtual bool | ReadByte (hf_u8_t &data) noexcept |
| | Read a single byte from the I2C device.
|
| |
| virtual bool | WriteRegister (hf_u8_t reg_addr, hf_u8_t data) noexcept |
| | Write to a register on the I2C device.
|
| |
| virtual bool | ReadRegister (hf_u8_t reg_addr, hf_u8_t &data) noexcept |
| | Read from a register on the I2C device.
|
| |
| virtual bool | ReadRegisters (hf_u8_t reg_addr, hf_u8_t *data, hf_u16_t length) noexcept |
| | Read multiple registers from the I2C device.
|
| |
| virtual hf_i2c_err_t | ResetStatistics () noexcept |
| | Reset I2C operation statistics.
|
| |
| virtual hf_i2c_err_t | ResetDiagnostics () noexcept |
| | Reset I2C diagnostic information.
|
| |
| virtual hf_i2c_err_t | GetStatistics (hf_i2c_statistics_t &statistics) const noexcept |
| | Get I2C operation statistics.
|
| |
| virtual hf_i2c_err_t | GetDiagnostics (hf_i2c_diagnostics_t &diagnostics) const noexcept |
| | Get I2C diagnostic information.
|
| |
Abstract base class for I2C device implementations.
This class provides a comprehensive I2C device abstraction that serves as the base for all I2C device implementations in the HardFOC system. Each instance represents a single I2C device with a pre-configured address. It supports:
- Master mode I2C communication
- Standard (100kHz) and Fast (400kHz) modes
- Read, write, and write-then-read operations
- Configurable timeouts and error handling
- Device presence detection
- Register-based communication utilities
- Lazy initialization pattern
Device address is configured during device creation and is not passed as a parameter to read/write operations, ensuring type safety and preventing accidental communication with wrong devices.
Derived classes implement platform-specific details such as:
- On-chip I2C controllers with device handles
- I2C bridge or adapter hardware
- Device-specific configurations
- Note
- This is a header-only abstract base class - instantiate concrete implementations instead.
-
This class is not inherently thread-safe. Use appropriate synchronization if accessed from multiple contexts.
-
Each BaseI2c instance represents a specific I2C device, not the I2C bus itself.