Skip to content

Commit

Permalink
[LPC824] I2C ROMAPI/bitrate related fix
Browse files Browse the repository at this point in the history
- I2C did not work as ROMAPI initialization override CFG register settings at i2c_init()
- i2c_frequency() ignored bitrate settings
  • Loading branch information
K4zuki committed Oct 26, 2014
1 parent 2fe9871 commit f39ea2e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC82X/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,14 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)

// enable power
i2c_power_enable(i2c_ch);
i2c_interface_enable(obj);

uint32_t size_in_bytes = LPC_I2CD_API->i2c_get_mem_size();
i2c_buffer = malloc(size_in_bytes);
obj->handler = LPC_I2CD_API->i2c_setup((uint32_t)(obj->i2c), i2c_buffer);
LPC_I2CD_API->i2c_set_bitrate(obj->handler, SystemCoreClock, 100000);
LPC_I2CD_API->i2c_set_timeout(obj->handler, 100000);

i2c_interface_enable(obj);
}

inline int i2c_start(i2c_t *obj)
Expand Down Expand Up @@ -211,7 +212,7 @@ static inline int i2c_do_read(i2c_t *obj, int last)

void i2c_frequency(i2c_t *obj, int hz)
{
LPC_I2CD_API->i2c_set_bitrate(obj->handler, SystemCoreClock, 100000);
LPC_I2CD_API->i2c_set_bitrate(obj->handler, SystemCoreClock, hz);
}

int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
Expand Down

0 comments on commit f39ea2e

Please sign in to comment.