summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
Diffstat (limited to 'digital')
-rw-r--r--digital/avr/make/Makefile.fsm100
-rw-r--r--digital/io/src/Makefile108
2 files changed, 112 insertions, 96 deletions
diff --git a/digital/avr/make/Makefile.fsm b/digital/avr/make/Makefile.fsm
new file mode 100644
index 00000000..38735b03
--- /dev/null
+++ b/digital/avr/make/Makefile.fsm
@@ -0,0 +1,100 @@
+# Makefile.fsm - Makefile to build FSM.
+
+# You need to define:
+# - FSM_SOURCES with the name of each of your FSM. For example, if you have
+# a example.fsm and check.fsm, you need to set FSM_SOURCES to "example
+# check".
+
+# FSM build:
+#
+# The %_cb.c file can not be auto-generated. When the %_cb_skel.c is changed,
+# user should check if they still are synchronised using a merge program, like
+# vimdiff.
+#
+# To help user, the user can define the CB variable to request a particular
+# behaviour.
+#
+# If CB=touch, ignore the auto-generation and touch the %_cb.c file.
+#
+# If CB=vimdiff, use vimdiff to merge differences.
+#
+# If CB=merge, try to merge automatically. In this case, it uses a old copy
+# of %_cb_skel.c to merge. This will fail the first time if no old copy is
+# available.
+
+# If templates are modified, files should be rebuilt.
+FSM_TEMPLATES := template_cb.h template_cb_decl.h template_cb_impl.c \
+ template_cb_skel.c template_fsm.c template_fsm.h
+FSM_TEMPLATES := $(FSM_TEMPLATES:%=fsm_templates/%)
+
+# Theses files are auto-generated, remove them on clean.
+EXTRA_CLEAN_FILES += $(FSM_SOURCES:%=%_fsm.h)
+EXTRA_CLEAN_FILES += $(FSM_SOURCES:%=%_fsm.c)
+EXTRA_CLEAN_FILES += $(FSM_SOURCES:%=%_cb.h)
+EXTRA_CLEAN_FILES += $(FSM_SOURCES:%=%_cb_skel.c)
+EXTRA_CLEAN_FILES += $(FSM_SOURCES:%=%.png)
+
+DFAGEN_DIR := $(BASE)/../../tools/dfagen
+DFAGEN_DEPS := $(DFAGEN_DIR)/dfagen.py
+DFAGEN := python $(DFAGEN_DIR)/dfagen.py
+
+# Add source to build.
+$(PROGS)_SOURCES += $(FSM_SOURCES:%=%.c)
+$(PROGS)_SOURCES += $(FSM_SOURCES:%=%_fsm.c)
+$(PROGS)_SOURCES += $(FSM_SOURCES:%=%_cb.c)
+$(PROGS)_SOURCES += fsm.c
+
+# Include general Makefile for first rule to be default.
+include $(BASE)/make/Makefile.gen
+
+# Bootstrap, fsm should be generated before fsm.h is used.
+fsm.c: fsm.h
+main.c: fsm.h
+fsm.h: $(FSM_SOURCES:%=%_fsm.h)
+
+$(DFAGEN_DIR)/dfagen.py: $(DFAGEN_DIR)/dfagen/parser.py
+$(DFAGEN_DIR)/dfagen/parser.py: $(DFAGEN_DIR)/dfagen/parser.g
+ yapps $<
+
+%_fsm.h %_fsm.c %_cb.h %_cb_skel.c: %.fsm fsm.conf $(FSM_TEMPLATES) \
+ $(DFAGEN_DEPS)
+ $(DFAGEN) -o c -d $< -c fsm.conf -p $(<:%.fsm=%)
+
+.PRECIOUS: $(FSM_SOURCES:%=%_cb.c)
+
+ifndef CB
+%_cb.c: %_cb_skel.c
+ @echo "Please update $@"
+ @false
+else ifeq ($(CB),touch)
+%_cb.c: %_cb_skel.c
+ @echo "Updating $@ blindly"
+ cp $< .$<.old
+ touch $@
+else ifeq ($(CB),merge)
+%_cb.c: %_cb_skel.c
+ @echo "Try to merge $@..."
+ @if [ -r .$<.old ]; then \
+ merge $@ .$<.old $<; \
+ RET=$$?; \
+ else \
+ echo "No history, cannot merge"; \
+ RET=1; \
+ fi; \
+ cp $< .$<.old; \
+ exit $$RET
+else
+%_cb.c: %_cb_skel.c
+ @echo "Using $(CB) to update $@"
+ cp $< .$<.old
+ $(CB) $@ $<
+endif
+
+
+png: $(FSM_SOURCES:%=%_cb.h)
+
+%.png: %.dot
+ dot -Tpng -o $@ $<
+
+%.dot: %.fsm $(DFAGEN_DEPS)
+ $(DFAGEN) -o dot -d $< -p $(<:%.fsm=%)
diff --git a/digital/io/src/Makefile b/digital/io/src/Makefile
index 548632d9..37c062a2 100644
--- a/digital/io/src/Makefile
+++ b/digital/io/src/Makefile
@@ -1,105 +1,21 @@
+# Base directory of AVR.
BASE = ../../avr
+# Name of the program to build.
PROGS = io
+# Sources to compile.
io_SOURCES = main.c asserv.c servo.avr.c eeprom.avr.c trap.c sharp.c \
switch.avr.c chrono.c \
- simu.host.c \
- fsm.c \
- getsamples.c getsamples_fsm.c getsamples_cb.c \
- gutter_fsm.c gutter_cb.c gutter.c \
- move.c move_fsm.c move_cb.c \
- top.c top_fsm.c top_cb.c
+ simu.host.c
+# Modules needed for IO.
MODULES = proto uart twi utils adc math/fixed path
+# Configuration file.
CONFIGFILE = avrconfig.h
-# atmega8, atmega8535, atmega128...
+# IO board use an ATMega128.
AVR_MCU = atmega128
-# -O2 : speed
-# -Os : size
+# Optimize for speed.
OPTIMIZE = -O2
-include $(BASE)/make/Makefile.gen
-
-# FSM build:
-#
-# The %_cb.c file can not be auto-generated. When the %_cb_skel.c is changed,
-# user should check if they still are synchronised using a merge program, like
-# vimdiff.
-#
-# To help user, the user can define the CB variable to request a particular
-# behaviour.
-#
-# If CB=touch, ignore the auto-generation and touch the %_cb.c file.
-#
-# If CB=vimdiff, use vimdiff to merge differences.
-#
-# If CB=merge, try to merge automatically. In this case, it uses a old copy
-# of %_cb_skel.c to merge. This will fail the first time if no old copy is
-# available.
-
-# If templates are modified, files should be rebuilt.
-FSM_TEMPLATES := template_cb.h template_cb_decl.h template_cb_impl.c \
- template_cb_skel.c template_fsm.c template_fsm.h
-FSM_TEMPLATES := $(FSM_TEMPLATES:%=fsm_templates/%)
-
-# Theses files are auto-generated, remove them on clean.
-EXTRA_CLEAN_FILES = getsamples_fsm.h getsamples_fsm.c getsamples_cb.h \
- getsamples_cb_skel.c getsamples.png \
- gutter_fsm.h gutter_fsm.c gutter_cb.h \
- gutter_cb_skel.c gutter.png \
- move_fsm.h move_fsm.c move_cb.h move_cb_skel.c move.png \
- top_fsm.h top_fsm.c top_cb.h top_cb_skel.c top.png
-
-# Bootstrap, fsm should be generated before fsm.h is used.
-fsm.c: fsm.h
-main.c: fsm.h
-fsm.h: getsamples_fsm.h gutter_fsm.h move_fsm.h top_fsm.h
-
-DFAGEN_DIR := $(BASE)/../../tools/dfagen
-DFAGEN_DEPS := $(DFAGEN_DIR)/dfagen.py
-DFAGEN := python $(DFAGEN_DIR)/dfagen.py
-
-$(DFAGEN_DIR)/dfagen.py: $(DFAGEN_DIR)/dfagen/parser.py
-$(DFAGEN_DIR)/dfagen/parser.py: $(DFAGEN_DIR)/dfagen/parser.g
- yapps $<
-
-%_fsm.h %_fsm.c %_cb.h %_cb_skel.c: %.fsm fsm.conf $(FSM_TEMPLATES) \
- $(DFAGEN_DEPS)
- $(DFAGEN) -o c -d $< -c fsm.conf -p $(<:%.fsm=%)
-
-.PRECIOUS: getsamples_cb.c gutter_cb.c move_cb.c top_cb.c
-
-ifndef CB
-%_cb.c: %_cb_skel.c
- @echo "Please update $@"
- @false
-else ifeq ($(CB),touch)
-%_cb.c: %_cb_skel.c
- @echo "Updating $@ blindly"
- cp $< .$<.old
- touch $@
-else ifeq ($(CB),merge)
-%_cb.c: %_cb_skel.c
- @echo "Try to merge $@..."
- @if [ -r .$<.old ]; then \
- merge $@ .$<.old $<; \
- RET=$$?; \
- else \
- echo "No history, cannot merge"; \
- RET=1; \
- fi; \
- cp $< .$<.old; \
- exit $$RET
-else
-%_cb.c: %_cb_skel.c
- @echo "Using $(CB) to update $@"
- cp $< .$<.old
- $(CB) $@ $<
-endif
-
-
-png: getsamples.png gutter.png move.png top.png
-
-%.png: %.dot
- dot -Tpng -o $@ $<
-
-%.dot: %.fsm $(DFAGEN_DEPS)
- $(DFAGEN) -o dot -d $< -p $(<:%.fsm=%)
+# FSMs.
+FSM_SOURCES := getsamples gutter move top
+# Include FSM makefile.
+include $(BASE)/make/Makefile.fsm