| |
Makefile
# Makefile for ATtiny15L projects
#
#############################################################################
#
# Copyright (c) 2002,2003,2004 Bruce D. Lightner (lightner@lightner.net)
#
# You may distribute and/or use for any purpose modified or unmodified
# copies of this software if you preserve the copyright notice above.
#
# THIS SOFTWARE IS PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED. IN NO EVENT WILL THE COPYRIGHT HOLDER
# BE LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE.
#
#############################################################################
#
# This Makefile assume a single "current project" named "project" Compiling
# and linking a project involves typing "make {project_name}".
#
# After this, use "make load" load to projct into a target ATtiny part via
# the programmer. This Makefile is setup to use the PicoWeb PC parallel
# port programmer (see http://www.picoweb.net/download/).
#
# Each "project" is expected to have a ".h" file which begins with the
# name of the project and ends with ".h". This C header file contains
# all the I/O definitions of that project, including the processor clock
# rate, the Vcc voltage of the part, the I/O pin definitions for things
# like the LEDs and serial ports. The "make project_name" logic copies
# this I/O definition header file into a file named "_io.h". This second
# file becomes the "current" project's I/O definition file.
#
# Notes:
#
# (1) This Makefile depends upon a number of the WinAVR "Unix-like"
# command-line programs like "rm", "cp", "diff", etc.
#
# (2) This logic only works with gcc version 2.95.2 19991024.
#
# (3) This Makefile assume the use of GNU make (a.k.a. avr-make).
#
# (4) The ATtiny serial programmer (avrtiny.exe) can uses the PC parallel
# port. This program works under Windows9x, and under WindowsXP with
# a special driver and I/O premissions "shim" program. The auther
# suggests that you use your own programmer. This Makefile produces
# Intel Hex output which should allow use with almost any AVR
# programmer.
#
# (5) This Makefile uses an AVR programmer which automatically reads
# the OSCCAL internal oscillator "calibration byte". The "make load"
# logic then puts this byte in the last location of program memory.
# Most of the sample programs use this byte and the macro "osccal() to
# read this byte value and "calibrate" the ATtiny internal oscillator.
# If *your* programmer does not do this, or and do not define the macro
# OSCCAL indicating where in program memory *you* have stored this
# value, then your oscillator will likely be "mis-calibrated" to 0xff!!
#
# (6) You will probably want to set your Windows PATH as follows:
#
# set PATH=c:\ATtiny\AVRSW\bin;%PATH%
#
# before using this software
#
# (7) This Makefile will work under Linux if you happen to have a
# gcc 2.95 release of avr-gcc (like I do!)
#
#############################################################################
MCU = attiny22
AVRSW = ../AVRSW
#LIBPATH = --library-path $(AVRSW)/lib
PROGRAMMER = $(AVRSW)/bin/avrtiny.exe
AR = $(AVRSW)/bin/avr-ar
AS = $(AVRSW)/bin/avr-as
CC = $(AVRSW)/bin/avr-gcc
LD = $(AVRSW)/bin/avr-ld
MAKE = $(AVRSW)/bin/avr-make
OBJCOPY = $(AVRSW)/bin/avr-objcopy
OBJDUMP = $(AVRSW)/bin/avr-objdump
PERL = $(AVRSW)/bin/perl
DIFF = $(AVRSW)/bin/diff -q
CP = $(AVRSW)/bin/cp
RM = $(AVRSW)/bin/rm
TOUCH = $(AVRSW)/bin/touch
#CFLAGS = -mmcu=$(MCU) -Os -mcall-prologues -Wall -Wmissing-prototypes
CFLAGS = -mmcu=$(MCU) -Os -mcall-prologues -Wall
LAST = project
LIB_OBJS = timer.o rand.o uart.o getchar.o putchar.o \
uart_rx.o uart_tx.o delay_ms.o delay_cs.o puthexb.o \
show_adc.o crlf.o pmputstr.o
all:
@echo "make what? candle, motor, utest, wdtest, avrprog, touch..."
avrprog:
-$(DIFF) $@.h _io.h || $(CP) $@.h _io.h
$(MAKE) $@.rom
wdtest:
-$(DIFF) $@.h _io.h || $(CP) $@.h _io.h
$(MAKE) $@.rom
motor:
-$(DIFF) $@.h _io.h || $(CP) $@.h _io.h
$(MAKE) $@.rom
motor2:
-$(DIFF) $@.h _io.h || $(CP) $@.h _io.h
$(MAKE) $@.rom
touch:
-$(DIFF) $@.h _io.h || $(CP) $@.h _io.h
$(MAKE) $@.rom
candle:
-$(DIFF) $@.h _io.h || $(CP) $@.h _io.h
$(MAKE) $@.rom
utest:
-$(DIFF) $@.h _io.h || $(CP) $@.h _io.h
$(MAKE) $@.rom
load: project.rom project.ep
$(PROGRAMMER) -ce -lp $(basename $<).rom -ap 511 OSCCAL -le $(basename $<).ep
$(PROGRAMMER) -en
sim: project.rom
$(RM) -f project.vcd
/avr/emulate/avr_emu -vcd project @project.sim
wave: project.vcd project.ini gtkwave.ini
c:/lightner/winwave/winwave.exe project.vcd project.ini
clean:
-$(RM) -f $(LIB_OBJS)
-$(RM) -f *.a
-$(RM) -f *.el
-$(RM) -f *.elf
-$(RM) -f *.hex
-$(RM) -f *.eep
-$(RM) -f *.ep
-$(RM) -f *.lst
-$(RM) -f *.map
-$(RM) -f *.o
-$(RM) -f *.rom
-$(RM) -f *.sym
@-$(RM) -f *.tmp
@-$(RM) -f *.vcd
candle.a: $(LIB_OBJS)
$(RM) -f $@
$(AR) -qs $@ $(LIB_OBJS)
.c.o:
$(CC) $(CFLAGS) -I $(AVRSW)/include -c -g -Wa,-almshd=$*.lst -o $*.o $*.c
perl chkinstr.pl $*.lst || ( $(RM) $*.o && exit 1 )
.s.o:
$(AS) -I $(AVRSW)/include -alms=$*.lst -o $*.o $*.s
%.hex: %.elf
$(OBJCOPY) -O ihex -R .eeprom $< $@
%.eep: %.elf
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $< $@
%.rom: %.hex
$(CP) $< $@
%.ep: %.eep
$(CP) $< $@
%.elf: %.o init.o candle.a tinyker.o tinyker.lds
@-$(RM) -f $*.hex
@-$(RM) -f $*.elf
@-$(RM) -f $*.rom
@-$(RM) -f $*.ep
@-$(RM) -f $*.sym
$(LD) -o $*.elf -Map $*.map $(LIBPATH) tinyker.o $*.o init.o \
candle.a --script tinyker.lds
@$(PERL) $(AVRSW)/bin/map2sym.pl $*.map > $*.sym
$(OBJCOPY) -O ihex -R .eeprom $*.elf $*.hex
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O ihex $*.elf $*.eep
$(CP) $*.hex $*.rom
$(CP) $*.eep $*.ep
@$(CP) -p $*.elf $(LAST).elf
@$(CP) -p $*.elf $(LAST).hex
@$(CP) -p $*.elf $(LAST).eep
@$(CP) -p $*.rom $(LAST).rom
@$(CP) -p $*.ep $(LAST).ep
@echo "" > $(LAST).el
@echo "" > $(LAST).vcd
@$(CP) -p $*.map $(LAST).map
@$(CP) -p $*.sym $(LAST).sym
@echo "current project is $*"
candle.o: candle.c _io.h iodefs.h timer.h rand.h crc.h uart.h progmem.h adc.h
motor.o: motor.c _io.h iodefs.h timer.h
motor2.o: motor2.c _io.h iodefs.h timer.h
touch.o: touch.c _io.h iodefs.h timer.h
avrprog.o: avrprog.c _io.h iodefs.h timer.h uart.h
utest.o: utest.c _io.h iodefs.h timer.h
iodefs.h: _io.h iotiny15.h
tinyker.o: tinyker.s
candle.rom: candle.o
init.o: init.s _io.h iodefs.h
timer.o: timer.c timer.h _io.h iodefs.h
uart.o: uart.c uart.h _io.h iodefs.h
uart.h: _io.h iodefs.h getchar.h putchar.h puthexb.h
getchar.o: getchar.c uart.h _io.h iodefs.h
putchar.o: putchar.c uart.h _io.h iodefs.h
uart_rx.o: uart_rx.c uart.h _io.h iodefs.h
uart_tx.o: uart_tx.c uart.h _io.h iodefs.h
delay_ms.o: delay_ms.c timer.h _io.h iodefs.h
delay_cs.o: delay_cs.c timer.h _io.h iodefs.h
puthexb.o: puthexb.c uart.h _io.h iodefs.h
crlf.o: crlf.c crlf.h uart.h _io.h iodefs.h
pmputstr.o: pmputstr.c pmputstr.h progmem.h uart.h _io.h iodefs.h
Back
|
|
|