mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Revision:
227:7bd0639b8911
Parent:
113:65a335a675de
Child:
294:78f9587bb26d
--- a/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c	Wed Jun 11 09:45:09 2014 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c	Wed Jun 11 16:00:09 2014 +0100
@@ -15,10 +15,12 @@
  *
  * Ported to NXP LPC43XX by Micromint USA <support@micromint.com>
  */
+#include "mbed_assert.h"
 #include "gpio_api.h"
 #include "pinmap.h"
 
 uint32_t gpio_set(PinName pin) {
+    MBED_ASSERT(pin != (PinName)NC);
     int f = 0;
     unsigned int port = (unsigned int)MBED_GPIO_PORT(pin);
 
@@ -29,9 +31,10 @@
 }
 
 void gpio_init(gpio_t *obj, PinName pin) {
-    if (pin == NC) return;
-    
     obj->pin = pin;
+    if (pin == (PinName)NC)
+        return;
+
     obj->mask = gpio_set(pin);
 
     LPC_GPIO_T *port_reg = (LPC_GPIO_T *) (LPC_GPIO_PORT_BASE);
@@ -48,8 +51,13 @@
 }
 
 void gpio_dir(gpio_t *obj, PinDirection direction) {
+    MBED_ASSERT(obj->pin != (PinName)NC);
     switch (direction) {
-        case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break;
-        case PIN_OUTPUT: *obj->reg_dir |=  obj->mask; break;
+        case PIN_INPUT :
+            *obj->reg_dir &= ~obj->mask;
+            break;
+        case PIN_OUTPUT:
+            *obj->reg_dir |=  obj->mask;
+            break;
     }
 }