[MAX326xx] Fixed i2c_byte_write() return value.

pull/2432/head
Jeremy Brodt 2016-08-16 10:28:56 -05:00
parent 0e330ef1fa
commit 301d7f271f
2 changed files with 7 additions and 7 deletions

View File

@ -228,11 +228,11 @@ int i2c_byte_write(i2c_t *obj, int data)
obj->i2c->trans |= MXC_F_I2CM_TRANS_TX_START; obj->i2c->trans |= MXC_F_I2CM_TRANS_TX_START;
// Wait for the FIFO to be empty // Wait for the FIFO to be empty
while(!(obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_FIFO_EMPTY)) {} while (!(obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_FIFO_EMPTY));
if (obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_NACKED) { if (obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_NACKED) {
i2c_reset(obj); i2c_reset(obj);
return 1; return 0;
} }
if (obj->i2c->intfl & (MXC_F_I2CM_INTFL_TX_TIMEOUT | MXC_F_I2CM_INTFL_TX_LOST_ARBITR)) { if (obj->i2c->intfl & (MXC_F_I2CM_INTFL_TX_TIMEOUT | MXC_F_I2CM_INTFL_TX_LOST_ARBITR)) {
@ -240,7 +240,7 @@ int i2c_byte_write(i2c_t *obj, int data)
return 2; return 2;
} }
return 0; return 1;
} }
int i2c_byte_read(i2c_t *obj, int last) int i2c_byte_read(i2c_t *obj, int last)

View File

@ -30,7 +30,7 @@
* ownership rights. * ownership rights.
******************************************************************************* *******************************************************************************
*/ */
#include "mbed_assert.h" #include "mbed_assert.h"
#include "i2c_api.h" #include "i2c_api.h"
#include "cmsis.h" #include "cmsis.h"
@ -228,11 +228,11 @@ int i2c_byte_write(i2c_t *obj, int data)
obj->i2c->trans |= MXC_F_I2CM_TRANS_TX_START; obj->i2c->trans |= MXC_F_I2CM_TRANS_TX_START;
// Wait for the FIFO to be empty // Wait for the FIFO to be empty
while(!(obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_FIFO_EMPTY)) {} while (!(obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_FIFO_EMPTY));
if (obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_NACKED) { if (obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_NACKED) {
i2c_reset(obj); i2c_reset(obj);
return 1; return 0;
} }
if (obj->i2c->intfl & (MXC_F_I2CM_INTFL_TX_TIMEOUT | MXC_F_I2CM_INTFL_TX_LOST_ARBITR)) { if (obj->i2c->intfl & (MXC_F_I2CM_INTFL_TX_TIMEOUT | MXC_F_I2CM_INTFL_TX_LOST_ARBITR)) {
@ -240,7 +240,7 @@ int i2c_byte_write(i2c_t *obj, int data)
return 2; return 2;
} }
return 0; return 1;
} }
int i2c_byte_read(i2c_t *obj, int last) int i2c_byte_read(i2c_t *obj, int last)