diff --git a/cores/nRF5/Arduino.h b/cores/nRF5/Arduino.h index 9a0880ef..93cb5a7b 100644 --- a/cores/nRF5/Arduino.h +++ b/cores/nRF5/Arduino.h @@ -106,12 +106,12 @@ uint32_t setLoopStacksize(void); #define bit(b) (1UL << (b)) -#define digitalPinToPort(P) ( &(NRF_GPIO[P]) ) -#define digitalPinToBitMask(P) ( 1 << g_ADigitalPinMap[P] ) +#define digitalPinToPort(P) ( NRF_P0 ) +#define digitalPinToBitMask(P) ( 1 << (P) ) //#define analogInPinToBit(P) ( ) -#define portOutputRegister(port) ( &(NRF_GPIO->OUT) ) -#define portInputRegister(port) ( &(NRF_GPIO->IN) ) -#define portModeRegister(port) ( &(NRF_GPIO->DIRSET) ) +#define portOutputRegister(port) ( &(port->OUT) ) +#define portInputRegister(port) ( &(port->IN) ) +#define portModeRegister(port) ( &(port->DIR) ) #define digitalPinHasPWM(P) ( (P) > 1 ) void rtos_idle_callback(void) ATTR_WEAK; diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino b/libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino index d06dacd6..88300403 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino @@ -410,7 +410,7 @@ uint32_t readPressedButtons(void) // Take current read and masked with BUTTONs // Note: Bitwise inverted since buttons are active (pressed) LOW - uint32_t debounced = ~(*portInputRegister(0)); + uint32_t debounced = ~(*portInputRegister( digitalPinToPort(0) )); debounced &= (bit(BUTTON_A) | bit(BUTTON_B) | bit(BUTTON_C)); // Copy current state into array