diff --git a/cores/nRF5/wiring_digital.c b/cores/nRF5/wiring_digital.c index 1d9c27fd..383c8ea1 100644 --- a/cores/nRF5/wiring_digital.c +++ b/cores/nRF5/wiring_digital.c @@ -111,6 +111,14 @@ int digitalRead( uint32_t ulPin ) return ((NRF_GPIO->IN >> ulPin) & 1UL) ? HIGH : LOW ; } +// TODO toggle not work !!! +int digitalToggle( uint32_t pin ) +{ + int state = 1 - (((NRF_GPIO->OUT >> pin) & 1UL) ? HIGH : LOW); + digitalWrite(pin, state); + return state; +} + #ifdef __cplusplus } #endif diff --git a/cores/nRF5/wiring_digital.h b/cores/nRF5/wiring_digital.h index 27b46a6b..e0d90528 100644 --- a/cores/nRF5/wiring_digital.h +++ b/cores/nRF5/wiring_digital.h @@ -64,6 +64,8 @@ extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) ; */ extern int digitalRead( uint32_t ulPin ) ; +extern int digitalToggle( uint32_t pin ); + #ifdef __cplusplus } #endif