t

Fork of mbed-dev by mbed official

Revision:
166:e614a9f1c9e2
Parent:
149:156823d33999
diff -r 289d4deac6e4 -r e614a9f1c9e2 targets/TARGET_NORDIC/TARGET_NRF5/pinmap.c
--- a/targets/TARGET_NORDIC/TARGET_NRF5/pinmap.c	Wed May 10 12:06:41 2017 +0100
+++ b/targets/TARGET_NORDIC/TARGET_NRF5/pinmap.c	Fri May 26 12:39:01 2017 +0100
@@ -16,6 +16,7 @@
 #include "mbed_assert.h"
 #include "mbed_error.h"
 #include "pinmap.h"
+#include "nrf_gpio.h"
 
 void pin_function(PinName pin, int function)
 {
@@ -29,7 +30,12 @@
     MBED_ASSERT(pin != (PinName)NC);
 
     uint32_t pin_number = (uint32_t)pin;
-
-    NRF_GPIO->PIN_CNF[pin_number] &= ~GPIO_PIN_CNF_PULL_Msk;
-    NRF_GPIO->PIN_CNF[pin_number] |= (mode << GPIO_PIN_CNF_PULL_Pos);
+    
+#ifdef TARGET_SDK11
+    NRF_GPIO_Type * reg = NRF_GPIO;
+#else
+    NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
+#endif
+    reg->PIN_CNF[pin_number] &= ~GPIO_PIN_CNF_PULL_Msk;
+    reg->PIN_CNF[pin_number] |= (mode << GPIO_PIN_CNF_PULL_Pos);
 }