Skip to content

Commit 929cf7f

Browse files
committed
Issue #666 LPC1768 i2c_slave_read fix
LPC1768 slave issues a STOP condition without waiting for master #666: https://developer.mbed.org/forum/bugs-suggestions/topic/5266/
1 parent 1c75638 commit 929cf7f

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. (See Image-2)
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)