Aleksey Kuleshov
2016-06-25 09:09:17 UTC
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?
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?