Skip to content

Commit c565c72

Browse files
committed
Update I2C Slave for lpc812
The dedicated I2C Slave byte read and byte write functions need to be called from 'common' mbed I2CSlave API for devices that have separate Master and Slave engines such as the lpc812 and lpc1549.
1 parent 90c1ccb commit c565c72

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

libraries/mbed/common/I2CSlave.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,33 @@ int I2CSlave::read(char *data, int length) {
4343
}
4444

4545
int I2CSlave::read(void) {
46+
// The dedicated I2C Slave byte read and byte write functions need to be called
47+
// from 'common' mbed I2CSlave API for devices that have separate Master and
48+
// Slave engines such as the lpc812 and lpc1549.
49+
//
50+
//#if defined (TARGET_LPC812) || defined (TARGET_LPC824) || defined (TARGET_LPC1549)
51+
#if defined (TARGET_LPC812)
52+
return i2c_slave_byte_read(&_i2c, 0);
53+
#else
4654
return i2c_byte_read(&_i2c, 0);
55+
#endif
4756
}
4857

4958
int I2CSlave::write(const char *data, int length) {
5059
return i2c_slave_write(&_i2c, data, length) != length;
5160
}
5261

5362
int I2CSlave::write(int data) {
63+
// The dedicated I2C Slave byte read and byte write functions need to be called
64+
// from 'common' mbed I2CSlave API for devices that have separate Master and
65+
// Slave engines such as the lpc812 and lpc1549.
66+
//
67+
//#if defined (TARGET_LPC812) || defined (TARGET_LPC824) || defined (TARGET_LPC1549)
68+
#if defined (TARGET_LPC812)
69+
return i2c_slave_byte_write(&_i2c, data);
70+
#else
5471
return i2c_byte_write(&_i2c, data);
72+
#endif
5573
}
5674

5775
void I2CSlave::stop(void) {

0 commit comments

Comments
 (0)