add digitalToggle() for convenience

This commit is contained in:
hathach committed 2017-01-09 16:00:53 +07:00
1 parent bee98fd16b
commit 30c735a68f
2 files changed
+10

No files matched your search

+8
View File
@@ -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
+2
View File
@@ -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