siva surendar / mbed-dev

Fork of mbed-dev by mbed official

Revision:
114:fe4fe5cfc3a3
Parent:
34:bb6061527455
Child:
144:ef7eb2e8f9f7
--- a/targets/hal/TARGET_STM/TARGET_STM32L0/i2c_api.c	Tue Apr 19 11:15:15 2016 +0100
+++ b/targets/hal/TARGET_STM/TARGET_STM32L0/i2c_api.c	Tue Apr 26 17:15:11 2016 +0100
@@ -48,7 +48,9 @@
 void i2c_init(i2c_t *obj, PinName sda, PinName scl)
 {
     static int i2c1_inited = 0;
+#if defined(I2C2_BASE)
     static int i2c2_inited = 0;
+#endif
 #if defined(I2C3_BASE)
     static int i2c3_inited = 0;
 #endif
@@ -72,6 +74,7 @@
         pin_mode(scl, OpenDrain);
     }
 
+#if defined(I2C2_BASE)
     // Enable I2C2 clock and pinout if not done
     if ((obj->i2c == I2C_2) && !i2c2_inited) {
         i2c2_inited = 1;
@@ -82,6 +85,7 @@
         pin_mode(sda, OpenDrain);
         pin_mode(scl, OpenDrain);
     }
+#endif
 
 #if defined(I2C3_BASE)
     // Enable I2C3 clock and pinout if not done
@@ -321,10 +325,12 @@
         __I2C1_FORCE_RESET();
         __I2C1_RELEASE_RESET();
     }
+#if defined(I2C2_BASE)
     if (obj->i2c == I2C_2) {
         __I2C2_FORCE_RESET();
         __I2C2_RELEASE_RESET();
     }
+#endif
 }
 
 #if DEVICE_I2CSLAVE