Skip to content

Commit eed91bc

Browse files
committed
Merge pull request #1473 from jamofer/master
Issue #666 LPC1768 i2c_slave_read fix
2 parents 1c75638 + e7d879a commit eed91bc

File tree

1 file changed

+9
-2
lines changed
  • libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X

1 file changed

+9
-2
lines changed

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,18 @@ int i2c_slave_read(i2c_t *obj, char *data, int length) {
350350
count++;
351351
} while (((status == 0x80) || (status == 0x90) ||
352352
(status == 0x060) || (status == 0x70)) && (count < length));
353-
353+
354+
// Clear old status and wait for Serial Interrupt.
355+
i2c_clear_SI(obj);
356+
i2c_wait_SI(obj);
357+
358+
// Obtain new status.
359+
status = i2c_status(obj);
360+
354361
if(status != 0xA0) {
355362
i2c_stop(obj);
356363
}
357-
364+
358365
i2c_clear_SI(obj);
359366

360367
return count;

0 commit comments

Comments
 (0)