Pure C Arduino Library
A set of API to ease up software development in C for Arduino
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Introduction & Library overview

The library is at the moment at a very early stage (alpha), but it is functional. The idea behind it is to simplify using Atmega328p peripherals, by creating a set of simple routines in order to configure and use it quickly. At the moment it has been tested and developed mostly on Arduino UNO rev 3 board, and for the time being is dedicated to this hardware.The library is written completely in C and is dedicated to speed up everyday C coding for Arduino platform without having a need to use the Arduino Library, which for the cost of simplifying development process (which is good), separates the user from the hardware quite mostly (which isn't that good).

Features

For the moment the following functionalities are implemented and tested:

  • Timer Delays (Arduino Library sleep/millis equivalent)
  • Timer PWM support
  • Beeper - Tone generation (Arduino Library tone equiv.)
  • Serial port support - Interrupt driven data reception, data reception by polling, data transmission by polling
  • SLIP protocol - serial line data synchronization protocol, to support binary data transfers over serial line
  • Simple ADC API
  • Simple GPIO abstraction layer
  • Software OneWire
  • I2C
  • SPI

The library implements basic device drivers for the following devices:

  • general 7 segment display driver - driver for LED 7 segment display, implementing interrupt driven multiplexing
  • ds1307 - an interface for the RTC clock to map it's internal registers
  • ds18b20 - Digital Temperature sensor, the driver is heavilly dependant on the software onewire implementation
  • hd44780 - hitachi display driver
  • pcd8544 - display driver for the NOKIA 3310 based LCDs

Using the documentation

For details regarding particular functionality please refer directly to a specific interface file.

Examples

Please refer to the provided examples as well for an overview on how to use a particular module.

Support

If you are unsure about the something you can also refer to my blog (http://pcarduino.blogspot.co.uk) dedicated to development in C for arduino platform, where I heavily use this library. You can also contact me through github.com/dagon666

Compiling with your own project

It is very simple to use this library with your own project. You can customize the config.h settings, pre-build it and then just simply link your project against the static library. Or you can include it as a compilation target in your Makefile. Below is an example Makefile for a simple project haing only one file: main.c. The following directory structure has been assumed:

*  .
*  | -- project
*  | ---- Makefile
*  | ---- main.c
*  | -- pca
*  | ---- ...
*
* 
TARGET=project_executable
SOURCES=main.c
DEPS=
COBJ=$(SOURCES:.c=.o)
PCA_PREFIX=../pca
CC=avr-gcc
OBJC=avr-objcopy
MCU=atmega328p
CFLAGS=-I. -I$(PCA_PREFIX)/include/ -Wall -Os -DF_CPU=16000000UL -std=c99
LDFLAGS=-lpca -L$(PCA_PREFIX)
all: $(TARGET)
%.o: %.c $(DEPS)
@echo -e "\tCC" $<
@$(CC) -mmcu=$(MCU) -c -o $@ $< $(CFLAGS)
libpca.a:
@echo -e "\tBUILDING PURE C ARDUINO LIB"
$(MAKE) -C $(PCA_PREFIX)
$(TARGET): $(COBJ) libpca.a
@echo -e "\tLINKING CC" $<
@$(CC) -mmcu=$(MCU) -o $(TARGET) $(COBJ) $(LDFLAGS)
$(OBJC) -O ihex -R .eeprom $(TARGET) $(TARGET).hex