Skip to content

Commit fb39286

Browse files
committed
Merge pull request #1560 from kgills/i2c_byte_write_fix
[MAX32600MBED MAXWSNENV] Fixing the return for i2c_byte_write.
2 parents 2d106cd + 9bc9668 commit fb39286

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

libraries/mbed/targets/hal/TARGET_Maxim/TARGET_MAX32600/i2c_api.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,17 @@ int i2c_byte_write(i2c_t *obj, int data)
227227

228228
obj->i2c->trans |= MXC_F_I2CM_TRANS_TX_START;
229229

230+
// Wait for the FIFO to be empty
231+
while(!(obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_FIFO_EMPTY)) {}
232+
233+
if(obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_NACKED) {
234+
return 1;
235+
}
236+
237+
if(obj->i2c->intfl & (MXC_F_I2CM_INTFL_TX_TIMEOUT | MXC_F_I2CM_INTFL_TX_LOST_ARBITR)) {
238+
return 2;
239+
}
240+
230241
return 0;
231242
}
232243

libraries/mbed/targets/hal/TARGET_Maxim/TARGET_MAX32610/i2c_api.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,17 @@ int i2c_byte_write(i2c_t *obj, int data)
227227

228228
obj->i2c->trans |= MXC_F_I2CM_TRANS_TX_START;
229229

230+
// Wait for the FIFO to be empty
231+
while(!(obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_FIFO_EMPTY)) {}
232+
233+
if(obj->i2c->intfl & MXC_F_I2CM_INTFL_TX_NACKED) {
234+
return 1;
235+
}
236+
237+
if(obj->i2c->intfl & (MXC_F_I2CM_INTFL_TX_TIMEOUT | MXC_F_I2CM_INTFL_TX_LOST_ARBITR)) {
238+
return 2;
239+
}
240+
230241
return 0;
231242
}
232243

0 commit comments

Comments
 (0)