C Function Library Code for Atmel AVR Processors
Code Files | Code Description |
avrlib.zip | Complete Library (all files listed below) |
AVRProject.dsp AVRProject.dsw |
Example project files for using AVR-GCC with
Microsoft Visual C++ 6.0 This Visual Studio project is an example project which contains all the code files listed below (the actual *.h and *.c files must also reside in the same directory). The project allows you to easily use MS VC++ to edit code for the AVR and has been configured so that clicking the "build" button in Visual Studio will run the AVR-GCC make causing your code to be compiled and errors reported into the build window. Additional information about how to use Visual Studio with AVR-GCC can be found here. |
makefile | Example makefile for compiling with AVR-GCC This heavily-commented makefile should make using it easier to understand. |
global.h | Global include File Defines commonly-used constants, variable types, and system characteristics. This file is used and needed by most of the avrlib function libraries. updated: 8/22/2002 |
a2d.h a2d.c |
Analog-to-Digital Converter Function Library This library provides an easy interface to the analog-to-digital converter available on many AVR processors. Updated to support the ATmega128. updated: 8/22/2002 |
ata_if.h ata_if.c |
IDE/ATA Interface Driver (for IDE/ATA hard disks) This library provides an interface from AVR processors to IDE/ATA hard disks. The library supports automatic drive identification and sector-level reading and writing. Some minimal address decoding hardware is required to use this interface. A schematic of the interface is coming. Future revisions may include a direct hardware-less option. updated: 6/06/2002 |
bitbuf.h bitbuf.c |
Generic Bit-Buffer Structure and Function Library This bit-buffer structure provides an easy and efficient way to store and process bits. You can create as many bit buffers as you like (within memory limits), and then use this common set of functions to access each buffer. Supported functions include sequential getting and storing of bits, array-like get, buffer flush (dump data), and reset-to-beginning. This buffer is not dynamically allocated, it has a user-defined fixed maximum size. updated: 7/10/2002 |
buffer.h buffer.c |
Generic Byte-Buffer Structure and Function
Library This byte-buffer structure provides an easy and efficient way to store and process a stream of bytes. You can create as many buffers as you like (within memory limits), and then use this common set of functions to access each buffer. The buffers are designed for FIFO operation (first in, first out). This means that the first byte you put in the buffer will be the first one you get when you read out the buffer. Supported functions include buffer initialize, get byte from front of buffer, add byte to end of buffer, check if buffer is full, and flush buffer. The buffer uses a circular design so no copying of data is ever necessary. This buffer is not dynamically allocated, it has a user-defined fixed maximum size. This buffer is used in many places in the avrlib code. updated: 6/06/2002 |
fat.h fat.c |
FAT16/32 File System Interface This FAT16/32 interface allows you to detect and mount FAT16/32 partitions, browse directories and files, and read file data. The interface is design to operate with the avrlib IDE/ATA driver. Reading FAT efficiently requires at least 512+ bytes of RAM so this interface may not be suitable for processors with less than 1K of RAM. This interface will properly follow a file's cluster chain so files need not be defragmented. updated: 12/12/2000 |
glcd.h glcd.c font5x7.h fontgr.h |
Graphic LCD API (application programmer's
interface) This library (or API) allows you to draw dots, lines, boxes, circles, and text on most monochrome graphic LCDs. An easily expandable font file (5x7-pixel characters) is provided for all basic ASCII characters (0x20-0x7F hex, 32-127 decimal). An expandable graphic font file is provided for defining specialty characters or custom icons. Because this library is designed to work with many different kinds of LCDs, it needs a graphic LCD driver such as ks0108.c to enable it to talk to the LCD. (for full text output functionality, you may wish to use the rprintf functions along with this driver) updated: 5/30/2002 |
gps.h gps.c |
GPS Positioning and Navigation Function Library (in development) This library provides a generic way to store and process information received from a GPS receiver. Currently the library only stores the most recent set of GPS data (position, velocity, time) from a GPS receiver. Future revisions will include navigation functions like calculate heading/distance to a waypoint. The processing of incoming serial data packets from GPS hardware is not done in this library. The libraries tsip.c and nmea.c do the packet processing for Trimble Standard Interface Protocol and NMEA-0813 repectively, and store the results in this library. updated: 9/2/2002 |
i2c.h i2c.c |
I2C Serial Interface Function Library This library provides the high-level functions needed to use the I2C serial interface supported by the hardware of several AVR processors. The library is functional but has not been fully tested yet and is still expanding. Thanks to the standardization of the I2C protocol and register access, the send and receive commands are everything you need to talk to thousands of different I2C devices including: EEPROMS, Flash memory, MP3 players, A/D and D/A converters, electronic potentiometers, etc. updated: 9/2/2002 |
i2csw.h i2csw.c |
Software-driven I2C Serial Interface Function Library This library provides a very simple bit-banged I2C serial interface. The library supports MASTER mode send and receive of single or multiple bytes. Thanks to the standardization of the I2C protocol and register access, the send and receive commands are everything you need to talk to thousands of different I2C devices including: EEPROMS, Flash memory, MP3 players, A/D and D/A converters, electronic potentiometers, etc. Although some AVR processors have built-in hardware to help create an I2C interface, this library does not use or require that hardware. updated: 6/06/2002 |
ks0108.h ks0108.c |
Graphic LCD Driver for HD61202/KS0108-based
Displays This display driver performs the basic functions necessary to access any graphic LCD based on the KS0108 or HD61202 controller chip. For more advanced functions, use this driver in conjunction with glcd.c. KS0108/HD61202 displays typically range in size from 64x32 pixels to 128x128 pixels and up to 3" square. To determine whether a display is compatible, you should look for the above controller chips to be mounted on the PC board attached to the display glass. The controller chips are about 1/2" x 3/4" and have 80+ pins. On larger displays, you may also see slave LCD driver chips with the numbers KS0107 or HD61203. The display will likely have an 18 or 20-pin interface. The interface from the LCD to an AVR processor does not require any additional hardware. If you can locate a datasheet for your display, that plus the information in the ks0108.h file should be all you need to get hooked up. A schematic of the interface wiring is coming. updated: 5/30/2002 |
lcd.h lcd.c |
Character LCD Driver for HD44780/SED1278-based
displays This display driver provides an interface to the most common type of character LCD, those based on the HD44780 or SED1278 controller chip (about 90% use one of these chips). The display driver can interface to the display through the CPU memory bus, or directly via I/O port pins. When using the direct I/O port mode, no additional interface hardware is needed except for a contrast potentiometer. Supported functions include initialization, clearing, scrolling, cursor positioning, text writing, and loading of custom characters or icons (up to 8). Although these displays are simple, clever use of the custom characters can allow you to create animations or simple graphics. A "progress bar" function is included in the driver. The driver now supports both 8-bit and 4-bit interface modes. (for full text output functionality, you may wish to use the rprintf functions along with this driver) updated: 9/17/2002 |
nmea.h nmea.c |
NMEA Packet Interface for GPS Receivers This library parses and decodes the standard NMEA data stream from a GPS and stores the position, velocity, and time solutions in the gps.c library. Library is not yet complete. updated: 9/2/2002 |
pulse.h pulse.c |
Pulse Function Library This library provides functions for generating pulses of arbitrary frequency and number. Common uses include stepper motor speed control, tone generation, communications, etc. This library requires a the timer function library. updated: 8/20/2002 |
rprintf.h rprintf.c |
A printf() Function Library (for general and
specific data
types) The rprintf function library provides a simplified (reduced) version of the common C printf() function. See the code files for details about which printf features are supported. Also in this library are a variety of functions for fast printing of certain common data types (variable types). Functions include print string from RAM, print string from ROM, print string snippet, print hex byte/short/long, and a custom-formatted number print. NOTE: All output from the rprintf library can be directed to any device or software which accepts characters. This means that rprintf output can be sent to the UART (serial port) or can be used with the LCD display libraries to print formatted text on the screen. updated: 8/23/2002 |
rtc.h rtc.c |
Real-Time Clock Function Library The RTC library provides everything you need to use the real-time clock resources present in many of the AVR processors. Once initialized, the RTC library keeps track of "human-format" time (HH:MM:SS and day/month/year) and that time can be used by other code. The time-keeping code is interrupt-driven and can be set or read at any time. This library requires real-time clock processor support and an external 32.768KHz crystal. Check your processor's datasheet to see if it supports RTC (in the timers section/chapter) updated: 7/12/2002 |
servo.h servo.c |
Interrupt-driven RC Servo Function Library A basic interrupt-driven function library that supports the continuous driving of up to eight RC hobby servos. The servos may be driven off any combination of I/O ports and pins. Works best at higher clock speeds 6-8MHz. (NOTE: this version is not compatible with the older AVR-GCC compiler. Get the latest version from here.) updated: 8/06/2002 |
spi.h spi.c |
SPI (Serial Peripheral Interface) Function
Library Provides basic byte and word transmitting and receiving via the AVR SPI interface. Due to the nature of SPI, every SPI communication operation is both a transmit and simultaneous receive. Currently, only MASTER mode is supported. updated: 6/06/2002 |
sta013.h sta013.c |
STMicroelectronics STA013 MP3 Player Driver This library interfaces to the I2C control port of the STA013 MP3 decoder chip. All functions necessary for setup and and control of the decoder chip are included. Supported functions include decoder initialize, decoder start, stop, pause, and resume, get bitrate and sample rate, set volume and tone controls. NOTE: the actual MP3 music data must be transmitted through a separate interface using SPI. The SPI function library is suitable for this. updated: 12/04/2000 |
swpwm.h swpwm.c |
Software Interrupt-driven Multi-output PWM
Function Library Provides up to 8 channels of PWM output at frequencies up to several hundred hertz. NOTE: works but not fully completed updated: 8/03/2002 |
swuart.h swuart.c |
Software Interrupt-driven UART Function Library This library provides one or two additional half-duplex serial ports to most AVR processors. The serial ports are half-duplex meaning NOTE: library not currently complete updated: 8/03/2002 |
timer.h timer.c |
Timer Function Library This library provides functions for use with the timers internal to the AVR processors. Functions include initialization, set prescaler, calibrated pause function (in milliseconds), attaching and detaching of user functions to interrupts, overflow counters, PWM. Arbitrary frequency generation has been moved to the Pulse Library. updated: 8/21/2002 |
timer128.h timer128.c |
Timer Function Library for the ATmega128 This library provides functions for use with the timers internal to the AVR ATmega128. Functions include initialization, set prescaler, calibrated pause function (in milliseconds), attaching and detaching of user functions to interrupts, overflow counters, and PWM (PWM is coming). updated: 8/23/2002 |
tsip.h tsip.c |
TSIP Packet Interface for Trimble GPS Receivers This library parses and decodes the TSIP data stream from a Trimble GPS and stores the position, velocity, and time solutions in the gps.c library. The library also includes functions to transmit TSIP packets to the GPS for configuration and data request. updated: 9/2/2002 |
uart.h uart.c |
UART (serial port) Driver/Function Library This library provides both buffered and unbuffered transmit and receive functions for the AVR processor UART. Buffered access means that the UART can transmit and receive data in the "background", while your code continues executing. Also included are functions to initialize the UART, set the baud rate, flush the buffers, and check buffer status. (for full text output functionality, you may wish to use the rprintf functions along with this driver) updated: 6/12/2002 |
uart2.h uart2.c |
Dual UART (serial port) Driver/Function Library
for the Mega161 and Mega128 This library provides both buffered and unbuffered transmit and receive functions for AVR processors with two UARTs. Buffered access means that the UART can transmit and receive data in the "background", while your code continues executing. Also included are functions to initialize the UART, set the baud rate, flush the buffers, and check buffer status. (for full text output functionality, you may wish to use the rprintf functions along with this driver) updated: 8/23/2002 |
vt100.h vt100.c |
VT100 Terminal Function Library This library provides functions for sending VT100 escape codes to control a connected VT100 or ANSI terminal. Commonly useful functions include setting the cursor position, clearing the screen, setting the text attributes (bold, inverse, blink, etc), and setting the text color. This library will slowly be expanded to include support for codes as needed and may eventually receive VT100 escape codes too. updated: 9/2/2002 |