libmaple/i2c.c
void i2c_bus_reset(const i2c_dev *dev) {
    /* Release both lines */
    i2c_master_release_bus(dev);

    /*
     * Make sure the bus is free by clocking it until any slaves release the
     * bus.
     */
    while (!gpio_read_bit(sda_port(dev), dev->sda_pin)) {
        /* Wait for any clock stretching to finish */
        while (!gpio_read_bit(scl_port(dev), dev->scl_pin))
            ;
        delay_us(10);

        /* Pull low */
        gpio_write_bit(scl_port(dev), dev->scl_pin, 0);
        delay_us(10);

        /* Release high again */
        gpio_write_bit(scl_port(dev), dev->scl_pin, 1);
        delay_us(10);
    }

    /* Generate start then stop condition */
    gpio_write_bit(sda_port(dev), dev->sda_pin, 0);
    delay_us(10);
    gpio_write_bit(scl_port(dev), dev->scl_pin, 0);
    delay_us(10);
    gpio_write_bit(scl_port(dev), dev->scl_pin, 1);
    delay_us(10);
    gpio_write_bit(sda_port(dev), dev->sda_pin, 1);
}
/**
 * @brief Reset an I2C bus.
 *
 * Reset is accomplished by clocking out pulses until any hung slaves
 * release SDA and SCL, then generating a START condition, then a STOP
 * condition.
 *
 * @param dev I2C device
 */
@brief Reset an I2C bus.
Reset is accomplished by clocking out pulses until any hung slaves
release SDA and SCL, then generating a START condition, then a STOP
condition.

@param dev I2C device
@brief Reset an I2C bus . Reset is accomplished by clocking out pulses until any hung slaves release SDA and SCL then generating a START condition then a STOP condition . @param dev I2C device
void i2c_bus_reset(const i2c_dev *dev) {
    i2c_master_release_bus(dev);
    while (!gpio_read_bit(sda_port(dev), dev->sda_pin)) {
        while (!gpio_read_bit(scl_port(dev), dev->scl_pin))
            ;
        delay_us(10);
        gpio_write_bit(scl_port(dev), dev->scl_pin, 0);
        delay_us(10);
        gpio_write_bit(scl_port(dev), dev->scl_pin, 1);
        delay_us(10);
    }
    gpio_write_bit(sda_port(dev), dev->sda_pin, 0);
    delay_us(10);
    gpio_write_bit(scl_port(dev), dev->scl_pin, 0);
    delay_us(10);
    gpio_write_bit(scl_port(dev), dev->scl_pin, 1);
    delay_us(10);
    gpio_write_bit(sda_port(dev), dev->sda_pin, 1);
}
void i2c_bus_reset ( const i2c_dev * dev ) { i2c_master_release_bus ( dev ) ; while ( ! gpio_read_bit ( sda_port ( dev ) , dev -> sda_pin ) ) { while ( ! gpio_read_bit ( scl_port ( dev ) , dev -> scl_pin ) ) ; delay_us ( 10 ) ; gpio_write_bit ( scl_port ( dev ) , dev -> scl_pin , 0 ) ; delay_us ( 10 ) ; gpio_write_bit ( scl_port ( dev ) , dev -> scl_pin , 1 ) ; delay_us ( 10 ) ; } gpio_write_bit ( sda_port ( dev ) , dev -> sda_pin , 0 ) ; delay_us ( 10 ) ; gpio_write_bit ( scl_port ( dev ) , dev -> scl_pin , 0 ) ; delay_us ( 10 ) ; gpio_write_bit ( scl_port ( dev ) , dev -> scl_pin , 1 ) ; delay_us ( 10 ) ; gpio_write_bit ( sda_port ( dev ) , dev -> sda_pin , 1 ) ; }
@brief Reset an I2C bus.
@brief Reset an I2C bus .
/* Release both lines */ /*
     * Make sure the bus is free by clocking it until any slaves release the
     * bus.
     */ /* Wait for any clock stretching to finish */ /* Pull low */ /* Release high again */ /* Generate start then stop condition */