mbed library sources

Fork of mbed-src by mbed official

Revision:
598:2d5fc5624619
Parent:
395:bfce16e86ea4
--- a/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/i2c_api.c	Mon Jul 27 09:45:08 2015 +0100
+++ b/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/i2c_api.c	Wed Jul 29 09:45:09 2015 +0100
@@ -17,6 +17,7 @@
 #include "i2c_api.h"
 #include "cmsis.h"
 #include "pinmap.h"
+#include "twi_master.h"
 #include "mbed_error.h"
 
 // nRF51822's I2C_0 and SPI_0 (I2C_1, SPI_1 and SPIS1) share the same address.
@@ -53,7 +54,8 @@
 
 void i2c_init(i2c_t *obj, PinName sda, PinName scl)
 {
-    NRF_TWI_Type *i2c;
+    twi_master_init_and_clear();
+    NRF_TWI_Type *i2c = NULL;
   
     if (i2c0_spi0_peripheral.usage == I2C_SPI_PERIPHERAL_FOR_I2C &&
             i2c0_spi0_peripheral.sda_mosi == (uint8_t)sda &&