This is a collection of inline functions and macros I use for programming my Arduino in pure old C. It enables me to write simply
pin12_mode_input();
instead of the more cryptic
DDRB &= ~(_BV(4));
and since GCC is clever there is absolutely no overhead in doing this.
My Arduino has an ATmega328P microprocessor running at 16MHz, and unfortunately this is all the headers support right now. If somebody wants to lend me an Arduino with another chip or clock speed I'd be happy to change this.
Here is a simple C program, which just blinks the diode connected to pin 13.
#include <util/delay.h>
#include <arduino/pins.h>
int main()
{
pin13_mode_output();
while (1) {
pin13_high();
_delay_ms(100.0);
pin13_low();
_delay_ms(900.0);
}
return 0;
}
See the doorduino code for a larger example. There you can also find a Makefile for compiling and uploading Arduino programs.
arduino-headers is free software. It is distributed under the terms of the GNU General Public License
Please send bug reports, patches, feature requests, praise and general gossip to me, Emil Renner Berthing [email protected].