[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] Convenient macros
From: |
Aleksey Kuleshov |
Subject: |
[avr-libc-dev] Convenient macros |
Date: |
Sat, 25 Jun 2016 12:09:17 +0300 |
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?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] Convenient macros,
Aleksey Kuleshov <=