|
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, uint64_t timeout_ns) |
| Write data to an I2C device. | |
| int | ove_hal_i2c_read (ove_i2c_t i2c, uint16_t addr, void *buf, size_t len, uint64_t timeout_ns) |
| 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, uint64_t timeout_ns) |
| Combined write-then-read with repeated start. | |
| int | ove_hal_i2c_write_read_async (ove_i2c_t i2c, uint16_t addr, const void *tx, size_t tx_len, void *rx, size_t rx_len) |
| Submit an async I2C write+read. | |
| void | ove_i2c_async_complete (ove_i2c_t i2c, int result) |
| Completion notification from the HAL. | |
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 | ) |
| int ove_hal_i2c_write | ( | ove_i2c_t | i2c, |
| uint16_t | addr, | ||
| const void * | data, | ||
| size_t | len, | ||
| uint64_t | timeout_ns | ||
| ) |
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_ns | Maximum wait time. |
| int ove_hal_i2c_read | ( | ove_i2c_t | i2c, |
| uint16_t | addr, | ||
| void * | buf, | ||
| size_t | len, | ||
| uint64_t | timeout_ns | ||
| ) |
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_ns | 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, | ||
| uint64_t | timeout_ns | ||
| ) |
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_ns | Maximum wait time. |
| int ove_hal_i2c_write_read_async | ( | ove_i2c_t | i2c, |
| uint16_t | addr, | ||
| const void * | tx, | ||
| size_t | tx_len, | ||
| void * | rx, | ||
| size_t | rx_len | ||
| ) |
Submit an async I2C write+read.
Optional HAL hook, gated by CONFIG_OVE_ASYNC. Backends must call ove_i2c_async_complete with the transaction result; the portable layer takes care of busy-flag clearing and user callback dispatch.
| [in] | i2c | I2C handle. |
| [in] | addr | 7-bit device address. |
| [in] | tx | Transmit buffer (may be NULL for pure read). |
| [in] | tx_len | Bytes to write. |
| [in] | rx | Receive buffer (may be NULL for pure write). |
| [in] | rx_len | Bytes to read. |
| void ove_i2c_async_complete | ( | ove_i2c_t | i2c, |
| int | result | ||
| ) |
Completion notification from the HAL.
Called by the HAL backend on transaction completion.
| [in] | i2c | I2C handle. |
| [in] | result | OVE_OK on success, negative error code on failure. |