davrlibs davrlibs
Status: Alpha
Brought to you by:
manveru6
#################### davrlibs preview release 0.0.3 README #################### 1. Overview Davrlibs is set of libraries, written mainly in C language, for doing common tasks in embedded systems development using Atmel AVR MCUs. It has been written by Michal Gawlik <manveru@post.pl> and released under terms of the BSD license (see LICENSE file). Currently it consists of: - 1-wire - Dallas-Maxim 1-Wire bus (currently, only DS18B20 digital thermometers are supported) - bootloader-host and bootloader-target - AVR bootloader support, compatible with Butterfly bootloader (AVR109) - common-func - common functions, like various optimized implementations of myitoa(), reset(), nop(), etc. - dds - library for handling DDS (Direct Digital Synthesis) chips. Currently only Analog Devices AD9833 is supported. - lcd-hd44780 - driver for character LCDs based on Hitachi HD44780 - lcd-t6963c - driver for graphic LCDs based on Toshiba T6963C - spi - driver for Atmel SPI interface - uart - driver for on-chip AVR UART IMPORTANT: This software should be considered as an alpha pre-release, provided "AS-IS". Although existing API is quite stable and usable, it can be changed in near future releases without earlier warnings. 2. Requirements - avr-gcc 4.2 or 4.3 (might work with elder versions, but it is untested) - avr-libc 1.6 (not tested with 1.4, but should work) - avrdude (if you want using simple "make upload" command to flash device) - some standard Unix tools like sed, grep, gawk, etc. OR - WinAVR toolchain (tested with version 20081205) 3. Instalation Just download sources and unpack them into your projects directory. It should look something like this: avr-projects/davrlibs/include avr-projects/davrlibs/lib avr-projects/davrlibs/src avr-projects/davrlibs-skel avr-projects/your-project-1 avr-projects/your-project-2 avr-projects/your-project-3 Then go to davrlibs directory and issue "make depend" and "make" commands to be sure if it compiles cleanly, without errors nor warnings. If you like risk, perhaps you should consider using development SVN version. But be warned, it could be VERY broken from time to time. 4. Using davrlibs a) Idea The idea behind directory organisation is to provide one library instance, in source form, for several independent user projects. Library is recompiled when needed, eg. when projects uses different hardware configurations or CPU clock speed. Recompilation is done automagically by Makefiles, you don't even need to think about it. b) Creating new project Copy directory "davrlibs-skel" and name it as you like, eg. "my project". Then edit some files: - davrlibs_devices_config.h - contains sample hardware configuration template. Should be customized to fit your project. - Makefile - contains definitions of target MCU and it's clock speed, list of source files of your project, programmer settings, library paths, etc. Most of those variables are documented in comments. And, happily, in common dayily usage, you should not need to change many of them. Most needed settings are placed at the beginning of the Makefile. - main.c - simple hello world app, provided as a simple example. Replace it with your own code. c) Adding library to user project Primo, include library header file (you will find them in include/davrlibs dir) in your source file, eg. "#include <davrlibs/uart.h>". Secundo, edit Makefile and add library to LIBS variable, eg. "-luart". Tertio, edit library hardware configuration file and provide valid configuration, eg. uart baudrate, frame format, etc (see template configuration file for examples). And thats all, now you should be able to use library functions. d) Adding new source file to your project Create new file and add it's name to SRC variable in Makefile. When adding new file, or changing "#include" directives, remember to use "make depend" command to ensure that Makefile has good description of dependencies between files in your project, and recompiles only what is really needed. e) Compiling your project Issue "make" command in your project directory. It checks if last library compilation is valid for current project, and if not, it recompiles needed libraries. Then it compiles your project, prepares programming files, etc. If you use avrdude uploader and have defined needed programming settings in Makefile, you could use "make upload" to build project and write it to flash memory of target device (eeprom is programmed only if needed, of course).