mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Revision:
227:7bd0639b8911
Parent:
149:1fb5f62b92bd
--- a/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_api.c	Wed Jun 11 09:45:09 2014 +0100
+++ b/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_api.c	Wed Jun 11 16:00:09 2014 +0100
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include "mbed_assert.h"
 #include "gpio_api.h"
 #include "pinmap.h"
 #include "fsl_port_hal.h"
@@ -20,6 +21,7 @@
 #include "fsl_sim_hal.h"
 
 uint32_t gpio_set(PinName pin) {
+    MBED_ASSERT(pin != (PinName)NC);
     uint32_t pin_num = pin & 0xFF;
 
     pin_function(pin, (int)kPortMuxAsGpio);
@@ -27,11 +29,10 @@
 }
 
 void gpio_init(gpio_t *obj, PinName pin) {
-    if (pin == NC) {
+    obj->pinName = pin;
+    if (pin == (PinName)NC)
         return;
-    }
 
-    obj->pinName = pin;
     uint32_t port = pin >> GPIO_PORT_SHIFT;
     uint32_t pin_num = pin & 0xFF;
     clock_hal_set_gate(kSimClockModulePORT, port, true);
@@ -43,6 +44,7 @@
 }
 
 void gpio_dir(gpio_t *obj, PinDirection direction) {
+    MBED_ASSERT(obj->pinName != (PinName)NC);
     uint32_t port = obj->pinName >> GPIO_PORT_SHIFT;
     uint32_t pin_num = obj->pinName & 0xFF;