i2c: Make i2c advance function match new prototypes
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -191,7 +191,7 @@ mraa_firmata_i2c_wait(int addr, int reg)
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
static int
|
||||
mraa_firmata_i2c_read_byte(mraa_i2c_context dev)
|
||||
{
|
||||
if (mraa_firmata_send_i2c_read_req(dev, 1) == MRAA_SUCCESS) {
|
||||
@@ -199,10 +199,10 @@ mraa_firmata_i2c_read_byte(mraa_i2c_context dev)
|
||||
return firmata_dev->i2cmsg[dev->addr][0];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
static int
|
||||
mraa_firmata_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
|
||||
{
|
||||
if (mraa_firmata_send_i2c_read_reg_req(dev, command, 2) == MRAA_SUCCESS) {
|
||||
@@ -215,10 +215,10 @@ mraa_firmata_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
|
||||
data = (data << 8) & 0xFF00;
|
||||
data |= high;
|
||||
|
||||
return data;
|
||||
return (int) data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -249,16 +249,16 @@ mraa_firmata_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
static int
|
||||
mraa_firmata_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
|
||||
{
|
||||
if (mraa_firmata_send_i2c_read_reg_req(dev, command, 1) == MRAA_SUCCESS) {
|
||||
if (mraa_firmata_i2c_wait(dev->addr, command) == MRAA_SUCCESS) {
|
||||
return firmata_dev->i2cmsg[dev->addr][command];
|
||||
return (int) firmata_dev->i2cmsg[dev->addr][command];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static mraa_result_t
|
||||
|
||||
@@ -550,17 +550,17 @@ mraa_ftdi_ft4222_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
static int
|
||||
mraa_ftdi_ft4222_i2c_read_byte(mraa_i2c_context dev)
|
||||
{
|
||||
uint8_t data;
|
||||
pthread_mutex_lock(&ft4222_lock);
|
||||
int bytes_read = mraa_ftdi_ft4222_i2c_context_read(dev, &data, 1);
|
||||
pthread_mutex_unlock(&ft4222_lock);
|
||||
return bytes_read == 1 ? data : 0;
|
||||
return bytes_read == 1 ? data : -1;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
static int
|
||||
mraa_ftdi_ft4222_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
|
||||
{
|
||||
uint8_t data;
|
||||
@@ -570,10 +570,13 @@ mraa_ftdi_ft4222_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
|
||||
if (bytesWritten == 1)
|
||||
bytes_read = mraa_ftdi_ft4222_i2c_context_read(dev, &data, 1);
|
||||
pthread_mutex_unlock(&ft4222_lock);
|
||||
return (bytes_read == 1) ? data : 0;
|
||||
if (bytes_read == 1) {
|
||||
return (int) data;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
static int
|
||||
mraa_ftdi_ft4222_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
@@ -584,8 +587,10 @@ mraa_ftdi_ft4222_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
|
||||
if (bytes_written == 1)
|
||||
bytes_read = mraa_ftdi_ft4222_i2c_context_read(dev, buf, 2);
|
||||
pthread_mutex_unlock(&ft4222_lock);
|
||||
data = (bytes_read == 2) ? *(uint16_t*)buf : 0;
|
||||
return data;
|
||||
if (bytes_read == 2) {
|
||||
return (int) data;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -600,7 +605,6 @@ mraa_ftdi_ft4222_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
|
||||
static mraa_result_t
|
||||
mraa_ftdi_ft4222_i2c_write(mraa_i2c_context dev, const uint8_t* data, int bytesToWrite)
|
||||
{
|
||||
@@ -618,7 +622,6 @@ mraa_ftdi_ft4222_i2c_write_byte(mraa_i2c_context dev, uint8_t data)
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static mraa_result_t
|
||||
mraa_ftdi_ft4222_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user