mbed library sources

Fork of mbed-src by mbed official

Revision:
227:7bd0639b8911
Parent:
19:398f4c622e1b
Child:
250:a49055e7a707
diff -r b062af740e40 -r 7bd0639b8911 targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.c
--- a/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.c	Wed Jun 11 09:45:09 2014 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.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 "pinmap.h"
 #include "error.h"
 
@@ -20,27 +21,27 @@
 #define LPC_IOCON1_BASE (LPC_IOCON_BASE + 0x60)
 
 void pin_function(PinName pin, int function) {
+    MBED_ASSERT(pin != (PinName)NC);
     if (pin == (PinName)NC) return;
     
     uint32_t pin_number = (uint32_t)pin;
     
     __IO uint32_t *reg = (pin_number < 32) ?
-            (__IO uint32_t*)(LPC_IOCON0_BASE + 4 * pin_number) :
-            (__IO uint32_t*)(LPC_IOCON1_BASE + 4 * (pin_number - 32));
+                         (__IO uint32_t*)(LPC_IOCON0_BASE + 4 * pin_number) :
+                         (__IO uint32_t*)(LPC_IOCON1_BASE + 4 * (pin_number - 32));
     
     // pin function bits: [2:0] -> 111 = (0x7)
     *reg = (*reg & ~0x7) | (function & 0x7);
 }
 
 void pin_mode(PinName pin, PinMode mode) {
-    if (pin == (PinName)NC) { return; }
-    
+    MBED_ASSERT(pin != (PinName)NC);
     uint32_t pin_number = (uint32_t)pin;
     uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2;
     
     __IO uint32_t *reg = (pin_number < 32) ?
-            (__IO uint32_t*)(LPC_IOCON0_BASE + 4 * pin_number) :
-            (__IO uint32_t*)(LPC_IOCON1_BASE + 4 * (pin_number - 32));
+                         (__IO uint32_t*)(LPC_IOCON0_BASE + 4 * pin_number) :
+                         (__IO uint32_t*)(LPC_IOCON1_BASE + 4 * (pin_number - 32));
     uint32_t tmp = *reg;
     
     // pin mode bits: [4:3] -> 11000 = (0x3 << 3)