completely redid PWM: Now calculate 'microprograms', i.e. pairs of
[moodlight.git] / Makefile
CommitLineData
ff29bc2b 1# $Id: Makefile,v 1.4 2010/07/24 20:56:28 simimeie Exp $
2d3643ee 2# Makefile for HaWo Moodlight
3
4CC = avr-gcc
5OBJDUMP = avr-objdump
6OBJCOPY = avr-objcopy
7#AVRDUDE = avrdude
8AVRDUDE = /opt/avrdude-5.10/bin/avrdude
9INCDIR = .
10# There are a few additional defines that en- or disable certain features,
11# mainly to save space in case you are running out of flash.
12# You can add them here.
13# -DJOKECMDS Just some joke commands
14ADDDEFS = -DJOKECMDS
15
16# target mcu (atmega328p or atmega168p)
17MCU = atmega328p
18# Since avrdude is generally crappy software (I liked uisp a lot better, too
19# bad the project is dead :-/), it cannot use the MCU name everybody else
20# uses, it has to invent its own name for it. So this defines the same
21# MCU as above, but with the name avrdude understands.
22AVRDMCU = m328p
23
24# Some more settings
25# Clock Frequency of the AVR. Needed for various calculations.
26CPUFREQ = 8000000UL
27# desired baudrate of serial debug console
28BAUDRATE = 9600UL
29
ff29bc2b 30SRCS = console.c ledframing.c ledpwm.c ircontrol.c timers.c main.c rfm12.c
2d3643ee 31PROG = moodlight
32
33# compiler flags
34CFLAGS = -g -Os -Wall -Wno-pointer-sign -mmcu=$(MCU) $(ADDDEFS)
35
36# linker flags
37LDFLAGS = -g -mmcu=$(MCU) -Wl,-Map,$(PROG).map
38
39CFLAGS += -DCPUFREQ=$(CPUFREQ) -DF_CPU=$(CPUFREQ) -DBAUDRATE=$(BAUDRATE)
40
41OBJS = $(SRCS:.c=.o)
42
43all: compile dump text eeprom
44 @echo -n "Compiled size: " && ls -l ${PROG}.bin
45
46compile: $(OBJS)
47 $(CC) $(LDFLAGS) -o $(PROG).elf $(OBJS)
48
49dump: compile
50 $(OBJDUMP) -h -S $(PROG).elf > $(PROG).lst
51
52%o : %c
53 $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
54
55# Create the flash contents
56text: compile
57 $(OBJCOPY) -j .text -j .data -O ihex $(PROG).elf $(PROG).hex
58 $(OBJCOPY) -j .text -j .data -O srec $(PROG).elf $(PROG).srec
59 $(OBJCOPY) -j .text -j .data -O binary $(PROG).elf $(PROG).bin
60
61# Rules for building the .eeprom rom images
62eeprom: compile
63 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $(PROG).elf $(PROG)_eeprom.hex
64 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $(PROG).elf $(PROG)_eeprom.srec
65 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $(PROG).elf $(PROG)_eeprom.bin
66
67clean:
68 rm -f $(PROG) *~ *.elf *.rom *.bin *.eep *.o *.lst *.map *.srec *.hex
69
70upload: uploadflash uploadeeprom
71
72uploadflash:
73 $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U flash:w:$(PROG).srec:s
74
75uploadeeprom:
76 $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U eeprom:w:$(PROG)_eeprom.srec:s
This page took 0.059767 seconds and 4 git commands to generate.