C library for Arduino – Preview
I’m working on a C library for Arduino hardware. The goal is to make it just as easy as the Arduino programming language but in plain standard C. The Arduino language is halfway between C and C++. While Arduino hardware uses the same Atmel atmega168 and atmega328 that I’ve come to love, the software does not allow me to code in standard C. It prevents one from being able to borrow all of the standard C and assembly (easily) that is out there for AVR micros. More importantly, it means that I have to load up a java IDE instead of just using the GNU command line tools such as avr-gcc, avr-libc, and make. By using the Arduino hardware, we get access to mass produced hardware and the Arduino bootloader. The Arduino hardware is handy because we can program it over the same interface as we use for printf() debugging. Also, since it can get its power over USB, it bundles up lots of the initial hurdles of getting started with micros.
Already the library supports:
serial – printf(), getchar(), etc
standard I/O – easily make pins input or output, set pins high and low
pwm – LED brightness, motor control
pwm servo – control RC servos
adc – read analog values
Here is a preview reading analog in with the ADC and controling the brightness of an LED using PWM:
I’m still working on making the wiki page match this blog and storing the code in SVN. For an early preview, check out http://tinkerish.com/wiki/.
Just started to work on making libarduino as a static lib and a makefile for inclusion on projects using libarduino
Will get back when I am getting closer
Awesome! I’m anxious to find out if the linker is smart enough to only pull in the functions that are used. In the old days (last time I checked), you had to separate things into groups of .c files that get built into separate .o files. It was smart enough to only pull in the things from the static library that came from a particular .o. It is the time that it would take to test and check this that has prevented me from moving from the #define method.
Good start! My first addition for libarduino was:
int check_serial(void)
{
if (uart_writeptr == uart_readptr)
return 0;
else return 1;
}
I think am finished. Well, for some kind of demo version at least.
Read more about it here:
http://www.sandklef.com/hesa/index.php/2010/01/29/libarduino-hacked-it-a-bit/
Basically, I have restructured the dir layout a bit and added a Makefile (for inclusion).
@mike
as far as the pulling things from .o files, I have done nada. But I am willing to