mbed library sources

Fork of mbed-src by mbed official

Revision:
367:d0878bd5474b
Parent:
366:2c37f9c21d44
--- a/targets/hal/TARGET_NXP/TARGET_LPC82X/i2c_api.c	Fri Oct 24 11:30:07 2014 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC82X/i2c_api.c	Sun Oct 26 13:45:07 2014 +0000
@@ -151,13 +151,14 @@
 
     // 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)
@@ -211,7 +212,7 @@
 
 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)