From: Brendan Le Foll Date: Fri, 11 Apr 2014 10:51:40 +0000 (+0100) Subject: i2c.cxx: add functionality to write to i2c X-Git-Tag: v0.2.0~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0504d0310e97d8a47f3f4858868235e29c35204f;p=contrib%2Fmraa.git i2c.cxx: add functionality to write to i2c Signed-off-by: Brendan Le Foll --- diff --git a/src/i2c/i2c.cxx b/src/i2c/i2c.cxx index 39ea2f0..2c591ad 100644 --- a/src/i2c/i2c.cxx +++ b/src/i2c/i2c.cxx @@ -64,12 +64,21 @@ I2C::read(int ack) int I2C::write(int address, const char *data, int length, bool repeated) { + if (i2c_smbus_write_i2c_block_data(i2c_handle, data[0], length, (uint8_t*) data) < 0) { + fprintf(stderr, "Failed to write to I2C slave\n"); + return -1; + } return 0; } int I2C::write(int data) { + if (i2c_smbus_write_byte(i2c_handle, data) < 0) { + fprintf(stderr, "Failed to write to I2C slave\n"); + return -1; + } + return 0; } void