Hello!

Maybe I just don't know something, but I made convenient macros which turns 
this code:
[code]
...
// For request
DDRA &= ~_BV(PA2);
// For LED
DDRB |= _BV(PB3);

// Wait for request
loop_until_bit_is_set(PINA, PA2);
// Turn LED on
PORTB |= _BV(PB3);
...
[/code]

into this completely equivalent code:

[code]
...

#define LED_PORT B
#define LED_PIN 3

#define REQ_PORT A
#define REQ_PIN 2

...

CONF_IN(REQ);
CONF_OUT(LED);

WAIT_1(REQ);
SET_1(LED);

...
[/code]

Note that in the first code it's easy to make a mistake and remember what 
port/pin is for.
The second code is self-explaining + no mentioned mistakes can ever be made!
Someone need this or it's just me who made bicycle?

_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to