mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Jan 27 13:30:08 2015 +0000
Parent:
454:a07e52520545
Child:
456:eac4c60f761b
Commit message:
Synchronized with git revision de09d163deef812a246ac8c48fb2978385bc7b53

Full URL: https://github.com/mbedmicro/mbed/commit/de09d163deef812a246ac8c48fb2978385bc7b53/

Changed in this revision

api/BusIn.h Show annotated file Show diff for this revision Revisions of this file
api/BusInOut.h Show annotated file Show diff for this revision Revisions of this file
api/BusOut.h Show annotated file Show diff for this revision Revisions of this file
api/DigitalIn.h Show annotated file Show diff for this revision Revisions of this file
api/DigitalInOut.h Show annotated file Show diff for this revision Revisions of this file
api/DigitalOut.h Show annotated file Show diff for this revision Revisions of this file
common/BusIn.cpp Show annotated file Show diff for this revision Revisions of this file
common/BusInOut.cpp Show annotated file Show diff for this revision Revisions of this file
common/BusOut.cpp Show annotated file Show diff for this revision Revisions of this file
hal/gpio_api.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_K20XX/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/gpio_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC82X/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_F334C8/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_L053C8/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F072RB/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F091RC/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_STM32F4/gpio_object.h Show annotated file Show diff for this revision Revisions of this file
--- a/api/BusIn.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/api/BusIn.h	Tue Jan 27 13:30:08 2015 +0000
@@ -58,15 +58,35 @@
      */
     void mode(PinMode pull);
 
+    /** Binary mask of bus pins connected to actual pins (not NC pins)
+     *  If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
+     *
+     *  @returns
+     *    Binary mask of connected pins
+     */
+    int mask() {
+        return _nc_mask;
+    }
+
 #ifdef MBED_OPERATORS
     /** A shorthand for read()
      */
     operator int();
+
+    /** Access to particular bit in random-iterator fashion
+     */
+    DigitalIn & operator[] (int index);
 #endif
 
 protected:
     DigitalIn* _pin[16];
 
+    /** Mask of bus's NC pins
+     * If bit[n] is set to 1 - pin is connected
+     * if bit[n] is cleared - pin is not connected (NC)
+     */
+    int _nc_mask;
+
     /* disallow copy constructor and assignment operators */
 private:
     BusIn(const BusIn&);
--- a/api/BusInOut.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/api/BusInOut.h	Tue Jan 27 13:30:08 2015 +0000
@@ -51,7 +51,6 @@
      */
     void write(int value);
 
-
     /** Read the value currently output on the bus
      *
      *  @returns
@@ -73,12 +72,26 @@
      */
     void mode(PinMode pull);
 
+    /** Binary mask of bus pins connected to actual pins (not NC pins)
+     *  If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
+     *
+     *  @returns
+     *    Binary mask of connected pins
+     */
+    int mask() {
+        return _nc_mask;
+    }
+
 #ifdef MBED_OPERATORS
      /** A shorthand for write()
      */
     BusInOut& operator= (int v);
     BusInOut& operator= (BusInOut& rhs);
 
+    /** Access to particular bit in random-iterator fashion
+    */
+    DigitalInOut& operator[] (int index);
+
     /** A shorthand for read()
      */
     operator int();
@@ -87,6 +100,12 @@
 protected:
     DigitalInOut* _pin[16];
 
+    /** Mask of bus's NC pins
+     * If bit[n] is set to 1 - pin is connected
+     * if bit[n] is cleared - pin is not connected (NC)
+     */
+    int _nc_mask;
+
     /* disallow copy constructor and assignment operators */
 private:
     BusInOut(const BusInOut&);
--- a/api/BusOut.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/api/BusOut.h	Tue Jan 27 13:30:08 2015 +0000
@@ -56,12 +56,26 @@
      */
     int read();
 
+    /** Binary mask of bus pins connected to actual pins (not NC pins)
+     *  If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
+     *
+     *  @returns
+     *    Binary mask of connected pins
+     */
+    int mask() {
+        return _nc_mask;
+    }
+
 #ifdef MBED_OPERATORS
     /** A shorthand for write()
      */
     BusOut& operator= (int v);
     BusOut& operator= (BusOut& rhs);
 
+    /** Access to particular bit in random-iterator fashion
+     */
+    DigitalOut& operator[] (int index);
+
     /** A shorthand for read()
      */
     operator int();
@@ -70,6 +84,12 @@
 protected:
     DigitalOut* _pin[16];
 
+    /** Mask of bus's NC pins
+     * If bit[n] is set to 1 - pin is connected
+     * if bit[n] is cleared - pin is not connected (NC)
+     */
+    int _nc_mask;
+
    /* disallow copy constructor and assignment operators */
 private:
     BusOut(const BusOut&);
--- a/api/DigitalIn.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/api/DigitalIn.h	Tue Jan 27 13:30:08 2015 +0000
@@ -80,6 +80,16 @@
         gpio_mode(&gpio, pull);
     }
 
+    /** Return the output setting, represented as 0 or 1 (int)
+     *
+     *  @returns
+     *    Non zero value if pin is connected to uc GPIO
+     *    0 if gpio object was initialized with NC
+     */
+    int is_connected() {
+        return gpio_is_connected(&gpio);
+    }
+
 #ifdef MBED_OPERATORS
     /** An operator shorthand for read()
      */
--- a/api/DigitalInOut.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/api/DigitalInOut.h	Tue Jan 27 13:30:08 2015 +0000
@@ -85,6 +85,16 @@
         gpio_mode(&gpio, pull);
     }
 
+    /** Return the output setting, represented as 0 or 1 (int)
+     *
+     *  @returns
+     *    Non zero value if pin is connected to uc GPIO
+     *    0 if gpio object was initialized with NC
+     */
+    int is_connected() {
+        return gpio_is_connected(&gpio);
+    }
+
 #ifdef MBED_OPERATORS
     /** A shorthand for write()
      */
--- a/api/DigitalOut.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/api/DigitalOut.h	Tue Jan 27 13:30:08 2015 +0000
@@ -77,6 +77,16 @@
         return gpio_read(&gpio);
     }
 
+    /** Return the output setting, represented as 0 or 1 (int)
+     *
+     *  @returns
+     *    Non zero value if pin is connected to uc GPIO
+     *    0 if gpio object was initialized with NC
+     */
+    int is_connected() {
+        return gpio_is_connected(&gpio);
+    }
+
 #ifdef MBED_OPERATORS
     /** A shorthand for write()
      */
--- a/common/BusIn.cpp	Tue Jan 27 07:15:07 2015 +0000
+++ b/common/BusIn.cpp	Tue Jan 27 13:30:08 2015 +0000
@@ -20,14 +20,22 @@
 BusIn::BusIn(PinName p0, PinName p1, PinName p2, PinName p3, PinName p4, PinName p5, PinName p6, PinName p7, PinName p8, PinName p9, PinName p10, PinName p11, PinName p12, PinName p13, PinName p14, PinName p15) {
     PinName pins[16] = {p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15};
 
+    _nc_mask = 0;
     for (int i=0; i<16; i++) {
         _pin[i] = (pins[i] != NC) ? new DigitalIn(pins[i]) : 0;
+        if (pins[i] != NC) {
+            _nc_mask |= (1 << i);
+        }
     }
 }
 
 BusIn::BusIn(PinName pins[16]) {
+    _nc_mask = 0;
     for (int i=0; i<16; i++) {
         _pin[i] = (pins[i] != NC) ? new DigitalIn(pins[i]) : 0;
+        if (pins[i] != NC) {
+            _nc_mask |= (1 << i);
+        }
     }
 }
 
@@ -61,6 +69,13 @@
 BusIn::operator int() {
     return read();
 }
+
+DigitalIn& BusIn::operator[] (int index) {
+    MBED_ASSERT(index >= 0 && index <= 16);
+    MBED_ASSERT(_pin[index]);
+    return *_pin[index];
+}
+
 #endif
 
 } // namespace mbed
--- a/common/BusInOut.cpp	Tue Jan 27 07:15:07 2015 +0000
+++ b/common/BusInOut.cpp	Tue Jan 27 13:30:08 2015 +0000
@@ -20,14 +20,22 @@
 BusInOut::BusInOut(PinName p0, PinName p1, PinName p2, PinName p3, PinName p4, PinName p5, PinName p6, PinName p7, PinName p8, PinName p9, PinName p10, PinName p11, PinName p12, PinName p13, PinName p14, PinName p15) {
     PinName pins[16] = {p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15};
 
+    _nc_mask = 0;
     for (int i=0; i<16; i++) {
         _pin[i] = (pins[i] != NC) ? new DigitalInOut(pins[i]) : 0;
+        if (pins[i] != NC) {
+            _nc_mask |= (1 << i);
+        }
     }
 }
 
 BusInOut::BusInOut(PinName pins[16]) {
+    _nc_mask = 0;
     for (int i=0; i<16; i++) {
         _pin[i] = (pins[i] != NC) ? new DigitalInOut(pins[i]) : 0;
+        if (pins[i] != NC) {
+            _nc_mask |= (1 << i);
+        }
     }
 }
 
@@ -92,6 +100,12 @@
     return *this;
 }
 
+DigitalInOut& BusInOut::operator[] (int index) {
+    MBED_ASSERT(index >= 0 && index <= 16);
+    MBED_ASSERT(_pin[index]);
+    return *_pin[index];
+}
+
 BusInOut::operator int() {
     return read();
 }
--- a/common/BusOut.cpp	Tue Jan 27 07:15:07 2015 +0000
+++ b/common/BusOut.cpp	Tue Jan 27 13:30:08 2015 +0000
@@ -20,14 +20,22 @@
 BusOut::BusOut(PinName p0, PinName p1, PinName p2, PinName p3, PinName p4, PinName p5, PinName p6, PinName p7, PinName p8, PinName p9, PinName p10, PinName p11, PinName p12, PinName p13, PinName p14, PinName p15) {
     PinName pins[16] = {p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15};
 
+    _nc_mask = 0;
     for (int i=0; i<16; i++) {
         _pin[i] = (pins[i] != NC) ? new DigitalOut(pins[i]) : 0;
+        if (pins[i] != NC) {
+            _nc_mask |= (1 << i);
+        }
     }
 }
 
 BusOut::BusOut(PinName pins[16]) {
+    _nc_mask = 0;
     for (int i=0; i<16; i++) {
         _pin[i] = (pins[i] != NC) ? new DigitalOut(pins[i]) : 0;
+        if (pins[i] != NC) {
+            _nc_mask |= (1 << i);
+        }
     }
 }
 
@@ -68,6 +76,12 @@
     return *this;
 }
 
+DigitalOut& BusOut::operator[] (int index) {
+    MBED_ASSERT(index >= 0 && index <= 16);
+    MBED_ASSERT(_pin[index]);
+    return *_pin[index];
+}
+
 BusOut::operator int() {
     return read();
 }
--- a/hal/gpio_api.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/hal/gpio_api.h	Tue Jan 27 13:30:08 2015 +0000
@@ -28,6 +28,12 @@
  **/
 uint32_t gpio_set(PinName pin);
 
+/* Checks if gpio object is connected (pin was not initialized with NC)
+ * @param pin The pin to be set as GPIO
+ * @return 0 if port is initialized with NC
+ **/
+int gpio_is_connected(const gpio_t *obj);
+
 /* GPIO object */
 void gpio_init(gpio_t *obj, PinName pin);
 
--- a/targets/hal/TARGET_Freescale/TARGET_K20XX/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_Freescale/TARGET_K20XX/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/gpio_api.c	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/gpio_api.c	Tue Jan 27 13:30:08 2015 +0000
@@ -30,7 +30,7 @@
 }
 
 void gpio_init(gpio_t *obj, PinName pin) {
-    obj->pinName = pin;
+    obj->pin = pin;
     if (pin == (PinName)NC)
         return;
 
@@ -42,14 +42,14 @@
 }
 
 void gpio_mode(gpio_t *obj, PinMode mode) {
-    pin_mode(obj->pinName, mode);
+    pin_mode(obj->pin, mode);
 }
 
 void gpio_dir(gpio_t *obj, PinDirection direction) {
-    MBED_ASSERT(obj->pinName != (PinName)NC);
-    uint32_t port = obj->pinName >> GPIO_PORT_SHIFT;
+    MBED_ASSERT(obj->pin != (PinName)NC);
+    uint32_t port = obj->pin >> GPIO_PORT_SHIFT;
     uint32_t gpio_addrs[] = GPIO_BASE_ADDRS;
-    uint32_t pin_num = obj->pinName & 0xFF;
+    uint32_t pin_num = obj->pin & 0xFF;
 
     switch (direction) {
         case PIN_INPUT:
--- a/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -25,27 +25,31 @@
 #endif
 
 typedef struct {
-    PinName pinName;
+    PinName pin;
 } gpio_t;
 
 static inline void gpio_write(gpio_t *obj, int value) {
-    MBED_ASSERT(obj->pinName != (PinName)NC);
-    uint32_t port = obj->pinName >> GPIO_PORT_SHIFT;
-    uint32_t pin = obj->pinName & 0xFF;
+    MBED_ASSERT(obj->pin != (PinName)NC);
+    uint32_t port = obj->pin >> GPIO_PORT_SHIFT;
+    uint32_t pin = obj->pin & 0xFF;
     uint32_t gpio_addrs[] = GPIO_BASE_ADDRS;
 
     GPIO_HAL_WritePinOutput(gpio_addrs[port], pin, value);
 }
 
 static inline int gpio_read(gpio_t *obj) {
-    MBED_ASSERT(obj->pinName != (PinName)NC);
-    uint32_t port = obj->pinName >> GPIO_PORT_SHIFT;
-    uint32_t pin = obj->pinName & 0xFF;
+    MBED_ASSERT(obj->pin != (PinName)NC);
+    uint32_t port = obj->pin >> GPIO_PORT_SHIFT;
+    uint32_t pin = obj->pin & 0xFF;
     uint32_t gpio_addrs[] = GPIO_BASE_ADDRS;
 
     return (int)GPIO_HAL_ReadPinInput(gpio_addrs[port], pin);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -43,6 +43,10 @@
     return ((*obj->reg_mask_read) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -46,6 +46,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -45,6 +45,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_NXP/TARGET_LPC82X/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC82X/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -47,6 +47,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -41,6 +41,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -64,6 +64,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -63,6 +63,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -64,6 +64,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F334C8/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F334C8/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -64,6 +64,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_DISCO_L053C8/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_L053C8/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -64,6 +64,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -64,6 +64,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F072RB/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F072RB/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -64,6 +64,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F091RC/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F091RC/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -64,6 +64,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif
--- a/targets/hal/TARGET_STM/TARGET_STM32F4/gpio_object.h	Tue Jan 27 07:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_STM32F4/gpio_object.h	Tue Jan 27 13:30:08 2015 +0000
@@ -64,6 +64,10 @@
     return ((*obj->reg_in & obj->mask) ? 1 : 0);
 }
 
+static inline int gpio_is_connected(const gpio_t *obj) {
+    return obj->pin != (PinName)NC;
+}
+
 #ifdef __cplusplus
 }
 #endif