diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/i2c_api.c index e399f62b20..5619a51435 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/i2c_api.c @@ -122,6 +122,15 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { pinmap_pinout(sda, PinMap_I2C_SDA); pinmap_pinout(scl, PinMap_I2C_SCL); + + // OpenDrain must explicitly be enabled for p0.0 and p0.1 + if (sda == P0_0) { + pin_mode(sda, OpenDrain); + } + if (scl == P0_1) { + pin_mode(scl, OpenDrain); + } + } inline int i2c_start(i2c_t *obj) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/port_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/port_api.c index 5f44eedd9e..8fe23e6dd0 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/port_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/port_api.c @@ -17,8 +17,9 @@ #include "pinmap.h" #include "gpio_api.h" + PinName port_pin(PortName port, int pin_n) { - return (PinName)(LPC_GPIO0_BASE + ((port << PORT_SHIFT) | pin_n)); + return (PinName)(((port << PORT_SHIFT) | pin_n)); } void port_init(port_t *obj, PortName port, int mask, PinDirection dir) {