mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Revision:
227:7bd0639b8911
Parent:
113:65a335a675de
--- a/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c	Wed Jun 11 09:45:09 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c	Wed Jun 11 16:00:09 2014 +0100
@@ -13,10 +13,12 @@
  * 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"
 
 uint32_t gpio_set(PinName pin) {
+    MBED_ASSERT(pin != (PinName)NC);
     uint32_t port_index = (uint32_t) pin >> 4;
 
     // Enable GPIO peripheral clock
@@ -27,9 +29,10 @@
 }
 
 void gpio_init(gpio_t *obj, PinName pin) {
-    if(pin == NC) return;
+    obj->pin = pin;
+    if (pin == (PinName)NC)
+        return;
 
-    obj->pin = pin;
     obj->mask = gpio_set(pin);
 
     uint32_t port_index = (uint32_t) pin >> 4;
@@ -46,8 +49,13 @@
 }
 
 void gpio_dir(gpio_t *obj, PinDirection direction) {
+    MBED_ASSERT(obj->pin != (PinName)NC);
     switch (direction) {
-        case PIN_INPUT : pin_function(obj->pin, STM_PIN_DATA(0, 0)); break;
-        case PIN_OUTPUT: pin_function(obj->pin, STM_PIN_DATA(1, 0)); break;
+        case PIN_INPUT :
+            pin_function(obj->pin, STM_PIN_DATA(0, 0));
+            break;
+        case PIN_OUTPUT:
+            pin_function(obj->pin, STM_PIN_DATA(1, 0));
+            break;
     }
 }