|
oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
|
Hardware Abstraction Layer interface for I2C bus operations. More...
Functions | |
| int | ove_hal_i2c_open (ove_i2c_t i2c, const struct ove_i2c_cfg *cfg) |
| Configure and enable the I2C peripheral. | |
| void | ove_hal_i2c_close (ove_i2c_t i2c) |
| Disable and release the I2C peripheral. | |
| int | ove_hal_i2c_write (ove_i2c_t i2c, uint16_t addr, const void *data, size_t len, uint32_t timeout_ms) |
| Write data to an I2C device. | |
| int | ove_hal_i2c_read (ove_i2c_t i2c, uint16_t addr, void *buf, size_t len, uint32_t timeout_ms) |
| Read data from an I2C device. | |
| int | ove_hal_i2c_write_read (ove_i2c_t i2c, uint16_t addr, const void *tx, size_t tx_len, void *rx, size_t rx_len, uint32_t timeout_ms) |
| Combined write-then-read with repeated start. | |
Hardware Abstraction Layer interface for I2C bus operations.
Declares the low-level I2C functions that every platform HAL must implement. The portable I2C layer delegates to these functions after performing parameter validation and bus locking.
| int ove_hal_i2c_open | ( | ove_i2c_t | i2c, |
| const struct ove_i2c_cfg * | cfg | ||
| ) |
Configure and enable the I2C peripheral.
Called by ove_i2c_init() after validation. The HAL must map the instance index to the correct hardware peripheral, configure the clock speed, and enable the I2C controller.
| [in] | i2c | I2C handle with storage already assigned. |
| [in] | cfg | Bus configuration descriptor. |
| void ove_hal_i2c_close | ( | ove_i2c_t | i2c | ) |
Disable and release the I2C peripheral.
Called by ove_i2c_deinit().
| [in] | i2c | I2C handle. |
| int ove_hal_i2c_write | ( | ove_i2c_t | i2c, |
| uint16_t | addr, | ||
| const void * | data, | ||
| size_t | len, | ||
| uint32_t | timeout_ms | ||
| ) |
Write data to an I2C device.
Called under the bus mutex.
| [in] | i2c | I2C handle. |
| [in] | addr | 7-bit device address. |
| [in] | data | Data to transmit. |
| [in] | len | Number of bytes. |
| [in] | timeout_ms | Maximum wait time. |
| int ove_hal_i2c_read | ( | ove_i2c_t | i2c, |
| uint16_t | addr, | ||
| void * | buf, | ||
| size_t | len, | ||
| uint32_t | timeout_ms | ||
| ) |
Read data from an I2C device.
Called under the bus mutex.
| [in] | i2c | I2C handle. |
| [in] | addr | 7-bit device address. |
| [out] | buf | Buffer to receive data. |
| [in] | len | Number of bytes. |
| [in] | timeout_ms | Maximum wait time. |
| int ove_hal_i2c_write_read | ( | ove_i2c_t | i2c, |
| uint16_t | addr, | ||
| const void * | tx, | ||
| size_t | tx_len, | ||
| void * | rx, | ||
| size_t | rx_len, | ||
| uint32_t | timeout_ms | ||
| ) |
Combined write-then-read with repeated start.
Called under the bus mutex. All four backends support this atomically (STM32 HAL_I2C_Mem_Read, Zephyr i2c_write_read, NuttX I2C_TRANSFER, POSIX I2C_RDWR).
| [in] | i2c | I2C handle. |
| [in] | addr | 7-bit device address. |
| [in] | tx | Transmit buffer. |
| [in] | tx_len | Number of bytes to write. |
| [out] | rx | Receive buffer. |
| [in] | rx_len | Number of bytes to read. |
| [in] | timeout_ms | Maximum wait time. |