summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blink/Makefile5
-rw-r--r--blink/blink.c2
-rw-r--r--include.mk24
-rw-r--r--lib/led.c (renamed from blink/led.c)0
-rw-r--r--lib/led.h (renamed from blink/led.h)0
-rw-r--r--lib/util.c (renamed from blink/util.c)0
-rw-r--r--lib/util.h (renamed from blink/util.h)0
7 files changed, 24 insertions, 7 deletions
diff --git a/blink/Makefile b/blink/Makefile
index 4f20366..86e960e 100644
--- a/blink/Makefile
+++ b/blink/Makefile
@@ -21,7 +21,8 @@
##
NAME := blink
-OBJ := blink.o util.o led.o
-BOARD_TYPE := AvrNetIo
+OBJ := blink.o
+LIBS := util led
+BOARD_TYPE := teensy2
include ../include.mk
diff --git a/blink/blink.c b/blink/blink.c
index ef1ebb0..726cc83 100644
--- a/blink/blink.c
+++ b/blink/blink.c
@@ -32,7 +32,7 @@ int main(void)
led_init();
for(;;) {
- _delay_ms(200);
+ _delay_ms(50);
led_toggle();
}
}
diff --git a/include.mk b/include.mk
index ce21fd7..92d6a0d 100644
--- a/include.mk
+++ b/include.mk
@@ -105,6 +105,7 @@ endif
CC = avr-gcc
OBJCOPY = avr-objcopy
+LIB_DIR = ../lib
DFU = dfu-programmer
teensy = teensy_loader_cli
@@ -123,6 +124,7 @@ CFLAGS += -fpack-struct
CFLAGS += -fshort-enums
CFLAGS += -Wall
CFLAGS += -Wstrict-prototypes
+CFLAGS += -I$(LIB_DIR)
CFLAGS += -DF_CPU=$(F_CPU)UL
CFLAGS += -D__BOARD_$(BOARD_TYPE)__
@@ -132,6 +134,10 @@ LDFLAGS +=
SRC := $(OBJ:%.o=%.c)
+OBJ_LIB := $(LIBS:%=lib-%.o)
+SRC_LIB := $(LIBS:%=$(LIB_DIR)/%.c)
+DEP_LIB := $(LIBS:%=lib-%.d)
+
.PHONY: clean program erase flash reset run
ELFFILE := $(NAME).elf
@@ -139,21 +145,31 @@ HEXFILE := $(NAME).hex
all: $(HEXFILE)
+lib-%.d: $(LIB_DIR)/%.c
+ @set -e; rm -f $@; \
+ $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,lib-\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$; echo '(re)building $@'
+
%.d: %.c
@set -e; rm -f $@; \
$(CC) -MM $(CFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$; echo '(re)building $@'
-ifneq ($(MAKECMDGOALS),distclean)
+ifneq ($(MAKECMDGOALS),clean)
-include $(SRC:%.c=%.d)
+-include $(DEP_LIB)
endif
+lib-%.o: $(LIB_DIR)/%.c
+ $(CC) $(CFLAGS) -o $@ -c $<
+
%.o: %.c
- $(CC) $(CFLAGS) -c $<
+ $(CC) $(CFLAGS) -o $@ -c $<
-$(ELFFILE): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+$(ELFFILE): $(OBJ) $(OBJ_LIB)
+ $(CC) $(OBJ) $(OBJ_LIB) -o $@ $(LDFLAGS)
$(HEXFILE): $(ELFFILE)
$(OBJCOPY) -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
diff --git a/blink/led.c b/lib/led.c
index 60436e2..60436e2 100644
--- a/blink/led.c
+++ b/lib/led.c
diff --git a/blink/led.h b/lib/led.h
index 12f00a8..12f00a8 100644
--- a/blink/led.h
+++ b/lib/led.h
diff --git a/blink/util.c b/lib/util.c
index 3bf17b1..3bf17b1 100644
--- a/blink/util.c
+++ b/lib/util.c
diff --git a/blink/util.h b/lib/util.h
index 15204b1..15204b1 100644
--- a/blink/util.h
+++ b/lib/util.h