mirror of
1
0
Fork 0

Add pin_toggle() macro.

This commit is contained in:
Mika Tuupola 2011-10-17 23:34:41 +03:00
parent 2043e1a496
commit 9e33675bec
2 changed files with 4 additions and 1 deletions

View File

@ -74,7 +74,8 @@ int main(void) {
while (1) {
/* Blink led by toggling state of PORTB5 (Arduino digital 13). */
PORTB ^= _BV(PORTB5);
//PORTB ^= _BV(PORTB5);
pin_toggle(13);
value = digital_read(2);
printf("%d", value);

View File

@ -527,6 +527,7 @@
//#define _D_READ(port_id, msk) ((PORTID_TO_INPUT_REG(port_id)) & (msk))
#define _D_READ(port_id, msk) (((PORTID_TO_INPUT_REG(port_id)) & (msk)) != 0 ? 1 : 0)
#define _D_TOGGLE(port_id, msk) PORTID_TO_OUTPUT_REG(port_id) ^= (msk)
/*
*
* NOTICE: for pins at timer0A/0B,
@ -560,6 +561,7 @@
#define pin_mode(pin, mode) SET_##mode(pin)
#define pin_pullup(pin, val) D_WRITE_##val(pin)
#define pin_toggle(pin) EXPAND_WRAPPER(_D_TOGGLE, ARDUINOPIN_TO_PORTID(pin), ARDUINOPIN_TO_PORTMSK(pin) )
#endif /* PINS_H */