components/i2c/master_i2c_interface.c
/**
 * @brief Test code to write esp-i2c-slave
 *        Master device write data to slave(both esp32),
 *        the data will be stored in slave buffer.
 *        We can read them out from slave buffer.
 *
 * ___________________________________________________________________
 * | start | slave_addr + wr_bit + ack | write n bytes + ack  | stop |
 * --------|---------------------------|----------------------|------|
 *
 */
@brief Test code to write esp-i2c-slave
Master device write data to slave(both esp32),
the data will be stored in slave buffer.
We can read them out from slave buffer.


@brief Test code to write esp - i2c - slave Master device write data to slave ( both esp32 ) the data will be stored in slave buffer . We can read them out from slave buffer .
esp_err_t i2c_master_write_slave(i2c_port_t i2c_num,
                                                int slave_address, 
                                                uint8_t* data_wr, 
                                                size_t size)
{
    i2c_cmd_handle_t cmd = i2c_cmd_link_create();
    i2c_master_start(cmd);
    i2c_master_write_byte(cmd, ( slave_address << 1 ) | WRITE_BIT, ACK_CHECK_EN);
    i2c_master_write(cmd, data_wr, size, ACK_CHECK_EN);
    i2c_master_stop(cmd);
    esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
    i2c_cmd_link_delete(cmd);
    return ret;
}
esp_err_t i2c_master_write_slave ( i2c_port_t i2c_num , int slave_address , uint8_t * data_wr , size_t size ) { i2c_cmd_handle_t cmd = i2c_cmd_link_create ( ) ; i2c_master_start ( cmd ) ; i2c_master_write_byte ( cmd , ( slave_address << 1 ) | WRITE_BIT , ACK_CHECK_EN ) ; i2c_master_write ( cmd , data_wr , size , ACK_CHECK_EN ) ; i2c_master_stop ( cmd ) ; esp_err_t ret = i2c_master_cmd_begin ( i2c_num , cmd , 1000 / portTICK_RATE_MS ) ; i2c_cmd_link_delete ( cmd ) ; return ret ; }
@brief Test code to write esp-i2c-slave
        Master device write data to slave(both esp32),
        the data will be stored in slave buffer.
@brief Test code to write esp - i2c - slave Master device write data to slave ( both esp32 ) the data will be stored in slave buffer .