Society of Robots - Robot Forum

Software => Software => Topic started by: pomprocker on July 31, 2008, 05:15:54 PM

Title: avrlib macros
Post by: pomprocker on July 31, 2008, 05:15:54 PM
Here are a couple good avrlib macros I came across while hanging out in arduino land

#define set_output(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define set_input(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))


#define high(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define low(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
Title: Re: avrlib macros
Post by: izua on July 31, 2008, 09:10:25 PM
that's nice, but IMO it's always better to use the bit operators instead of macros.
this way everyone who reads your code will know easily what's going on.