From adcefeaba1d01ec074d4affe676c573d27697ebb Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Mon, 19 May 2014 10:34:36 +0100 Subject: [PATCH] i2c: fix write API to use const char* Signed-off-by: Brendan Le Foll --- api/i2c.h | 6 +++--- api/i2c.hpp | 6 +++--- src/i2c/i2c.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/i2c.h b/api/i2c.h index dbf3e6e..ae05b53 100644 --- a/api/i2c.h +++ b/api/i2c.h @@ -77,7 +77,7 @@ maa_result_t maa_i2c_frequency(maa_i2c_context dev, int hz); * * @return maa_result_t the maa result. */ -maa_result_t maa_i2c_read(maa_i2c_context dev, const char *data, int length); +maa_result_t maa_i2c_read(maa_i2c_context dev, char *data, int length); /** Read a single byte from the i2c context * @@ -95,7 +95,7 @@ int maa_i2c_read_byte(maa_i2c_context dev); * * @return maa_result_t the maa result. */ -maa_result_t maa_i2c_write(maa_i2c_context dev, char *data, int length); +maa_result_t maa_i2c_write(maa_i2c_context dev, const char *data, int length); /** Write a single byte to an i2c context * @@ -104,7 +104,7 @@ maa_result_t maa_i2c_write(maa_i2c_context dev, char *data, int length); * * @return maa_result_t the maa result. */ -maa_result_t maa_i2c_write_byte(maa_i2c_context dev, int data); +maa_result_t maa_i2c_write_byte(maa_i2c_context dev, const int data); /** Sets the i2c context address. * diff --git a/api/i2c.hpp b/api/i2c.hpp index f683446..7da3ac0 100644 --- a/api/i2c.hpp +++ b/api/i2c.hpp @@ -54,13 +54,13 @@ class I2c { int read_byte() { return maa_i2c_read_byte(m_i2c); } - maa_result_t read(const char *data, int length) { + maa_result_t read(char *data, int length) { return maa_i2c_read(m_i2c, data, length); } - maa_result_t write(char *data, int length) { + maa_result_t write(const char *data, int length) { return maa_i2c_write(m_i2c, data, length); } - maa_result_t write_byte(int data) { + maa_result_t write_byte(const int data) { return maa_i2c_write_byte(m_i2c, data); } private: diff --git a/src/i2c/i2c.c b/src/i2c/i2c.c index 39a8f5f..496ede9 100644 --- a/src/i2c/i2c.c +++ b/src/i2c/i2c.c @@ -78,7 +78,7 @@ maa_i2c_frequency(maa_i2c_context dev, int hz) } maa_result_t -maa_i2c_read(maa_i2c_context dev, const char *data, int length) +maa_i2c_read(maa_i2c_context dev, char *data, int length) { // this is the read(3) syscall not maa_i2c_read() if (read(dev->fh, data, length) == length) { @@ -99,7 +99,7 @@ maa_i2c_read_byte(maa_i2c_context dev) } maa_result_t -maa_i2c_write(maa_i2c_context dev, char* data, int length) +maa_i2c_write(maa_i2c_context dev, const char* data, int length) { if (i2c_smbus_write_i2c_block_data(dev->fh, data[0], length-1, (uint8_t*) data+1) < 0) { fprintf(stderr, "Failed to write to i2c\n"); @@ -109,7 +109,7 @@ maa_i2c_write(maa_i2c_context dev, char* data, int length) } maa_result_t -maa_i2c_write_byte(maa_i2c_context dev, int data) +maa_i2c_write_byte(maa_i2c_context dev, const int data) { if (i2c_smbus_write_byte(dev->fh, data) < 0) { fprintf(stderr, "Failed to write to i2c\n"); -- 2.7.4