144 uint32_t timeout_ms);
160 size_t len, uint32_t timeout_ms);
176 size_t len, uint32_t timeout_ms);
hw_i2c_t hw_i2c_init_default(uint32_t baudrate)
Initialize an I2C interface using default pins and adapter.
struct hw_i2c_t hw_i2c_t
I2C adapter.
static bool hw_i2c_valid(hw_i2c_t *i2c)
Get true if the I2C interface is valid.
hw_gpio_t sda
I2C data pin number.
GPIO (General Purpose Input/Output) interface.
uint32_t baudrate
I2C baud rate in Hz.
size_t hw_i2c_xfr(hw_i2c_t *i2c, uint8_t addr, void *data, size_t tx, size_t rx, uint32_t timeout_ms)
Perform an I2C transfer operation (read, write, or combined).
hw_gpio_t scl
I2C clock pin number.
bool hw_i2c_detect(hw_i2c_t *i2c, uint8_t addr)
Detect if an I2C device is present at the specified address.
void hw_i2c_finalize(hw_i2c_t *i2c)
Finalize and release an I2C interface.
size_t hw_i2c_write(hw_i2c_t *i2c, uint8_t addr, uint8_t reg, const void *data, size_t len, uint32_t timeout_ms)
Write data to a specific register of an I2C device.
uint8_t reserved[3]
Reserved for user data.
size_t hw_i2c_read(hw_i2c_t *i2c, uint8_t addr, uint8_t reg, void *data, size_t len, uint32_t timeout_ms)
Read data from a specific register of an I2C device.
uint8_t hw_i2c_count(void)
Get the total number of available I2C adapters.
hw_i2c_t hw_i2c_init(uint8_t adapter, uint8_t sda, uint8_t scl, uint32_t baudrate)
Initialize an I2C interface with specific adapter and pins.
uint8_t adapter
I2C adapter number (0, 1, etc.)
GPIO logical pin structure.