[NUC472/M453] Fix I2C issues

1. Fix error on return of i2c_byte_write().
2. Fix error in zero-length transfer corner case.
pull/3309/head
ccli8 2016-11-10 16:19:47 +08:00
parent f4007e296d
commit 657d90db2c
2 changed files with 10 additions and 2 deletions

View File

@ -221,7 +221,7 @@ int i2c_byte_read(i2c_t *obj, int last)
int i2c_byte_write(i2c_t *obj, int data)
{
return i2c_do_write(obj, (data & 0xFF), 0);
return i2c_do_write(obj, (data & 0xFF), 0) == 0 ? 1 : 0;
}
#if DEVICE_I2CSLAVE
@ -352,6 +352,10 @@ int i2c_allow_powerdown(void)
static int i2c_do_tran(i2c_t *obj, char *buf, int length, int read, int naklastdata)
{
if (! buf || ! length) {
return 0;
}
int tran_len = 0;
i2c_disable_int(obj);

View File

@ -238,7 +238,7 @@ int i2c_byte_read(i2c_t *obj, int last)
int i2c_byte_write(i2c_t *obj, int data)
{
return i2c_do_write(obj, (data & 0xFF), 0);
return i2c_do_write(obj, (data & 0xFF), 0) == 0 ? 1 : 0;
}
#if DEVICE_I2CSLAVE
@ -369,6 +369,10 @@ int i2c_allow_powerdown(void)
static int i2c_do_tran(i2c_t *obj, char *buf, int length, int read, int naklastdata)
{
if (! buf || ! length) {
return 0;
}
int tran_len = 0;
i2c_disable_int(obj);