riot_sys

Function i2c_write_reg

Source
pub unsafe extern "C" fn i2c_write_reg(
    dev: i2c_t,
    addr: u16,
    reg: u16,
    data: u8,
    flags: u8,
) -> c_int
Expand description

@brief Convenience function for writing one byte to a given register address

@note This function is using a continuous sequence for writing to the specified register address. It first writes the register then data.

@pre i2c_acquire must be called before accessing the bus

@param[in] dev I2C peripheral device @param[in] reg register address to read from (8- or 16-bit, right-aligned) @param[in] addr 7-bit or 10-bit device address (right-aligned) @param[in] data byte to write @param[in] flags optional flags (see @ref i2c_flags_t)

@return 0 When success @return -EIO When slave device doesn’t ACK the byte @return -ENXIO When no devices respond on the address sent on the bus @return -ETIMEDOUT When timeout occurs before device’s response @return -EINVAL When an invalid argument is given @return -EOPNOTSUPP When MCU driver doesn’t support the flag operation @return -EAGAIN When a lost bus arbitration occurs