summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware/Makefile
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2008-10-09 20:57:51 +0200
committerMichael Buesch <mb@bu3sch.de>2008-10-09 20:57:51 +0200
commit92af9d1735aab816bca994f513314cdcc8b9bd66 (patch)
tree70e346613cb271e78b79167d3993885c0ca5bbef /pressure_control/firmware/Makefile
parent5522cb6f66bea3b27134f6a4517e8472b7226bda (diff)
downloadcnc-92af9d1735aab816bca994f513314cdcc8b9bd66.tar.xz
cnc-92af9d1735aab816bca994f513314cdcc8b9bd66.zip
Add pressure_control firmware skeleton.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'pressure_control/firmware/Makefile')
-rw-r--r--pressure_control/firmware/Makefile92
1 files changed, 92 insertions, 0 deletions
diff --git a/pressure_control/firmware/Makefile b/pressure_control/firmware/Makefile
new file mode 100644
index 0000000..30eaaf6
--- /dev/null
+++ b/pressure_control/firmware/Makefile
@@ -0,0 +1,92 @@
+ARCH ?= atmega8
+AVRDUDE_ARCH ?= m8
+AVRDUDE ?= avrdude
+AVRDUDE_SPEED ?= 1
+PROGRAMMER ?= avrisp2
+PROGPORT ?= usb
+
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+SIZE = avr-size
+
+CFLAGS = -mmcu=$(ARCH) -std=gnu99 -g0 -O2 -fomit-frame-pointer -Wall -fpack-struct
+CFLAGS += "-Dinline=inline __attribute__((__always_inline__))"
+
+
+# The fuse bits
+LFUSE = 0xE0
+HFUSE = 0xD9
+
+OBJECTS = main.o util.o
+NAME = pressure_control
+
+BIN = $(NAME).bin
+HEX = $(NAME).hex
+EEP = $(NAME).eep.hex
+
+all: $(HEX)
+
+main.o: util.h
+
+util.o: util.h calibration.h
+
+%.s: %.c
+ $(CC) $(CFLAGS) -S $*.c
+
+$(BIN): $(OBJECTS)
+ $(CC) $(CFLAGS) -o $(BIN) $(OBJECTS) $(LDFLAGS)
+
+$(HEX): $(BIN)
+ $(OBJCOPY) -R.eeprom -O ihex $(BIN) $(HEX)
+# $(OBJCOPY) -j.eeprom --set-section-flags=.eeprom="alloc,load" \
+# --change-section-lma .eeprom=0 -O ihex $(BIN) $(EEP)
+ $(SIZE) $(BIN)
+
+avrdude:
+ $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
+ -c $(PROGRAMMER) -P $(PROGPORT) -t
+
+install_flash:
+ $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
+ -c $(PROGRAMMER) -P $(PROGPORT) -U flash:w:$(HEX)
+
+install_eeprom:
+ $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
+ -c $(PROGRAMMER) -P $(PROGPORT) -U eeprom:w:$(EEP)
+
+install: all install_flash
+
+# Reset the microcontroller through avrdude
+reset:
+ $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
+ -c $(PROGRAMMER) -P $(PROGPORT) \
+ -U signature:r:/dev/null:i -q -q
+
+writefuse:
+ $(AVRDUDE) -B 100 -p $(AVRDUDE_ARCH) \
+ -c $(PROGRAMMER) -P $(PROGPORT) -q -q \
+ -U lfuse:w:$(LFUSE):m \
+ -U hfuse:w:$(HFUSE):m
+
+clean:
+ -rm -f *~ *.o $(BIN)
+
+distclean: clean
+ -rm -f *.s $(HEX) $(EEP)
+
+help:
+ @echo "Makefile"
+ @echo ""
+ @echo "Targets:"
+ @echo " all - build the firmware (default target)"
+ @echo " clean - remove object files"
+ @echo " distclean - remove object, binary and hex files"
+ @echo ""
+ @echo "Targets that operate on the device through avrdude:"
+ @echo " install - flash the program code"
+ @echo " writefuse - write the fuse bits"
+ @echo " reset - pull the external device reset pin"
+ @echo " avrdude - run avrdude in interactive mode"
+ @echo ""
+ @echo "Generic targets:"
+ @echo " *.s - create an assembly file from a *.c file"
bues.ch cgit interface