summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-08-17 13:53:33 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-08-17 13:53:33 +0200
commit29414b3003eafb1fd82c14893fb64805dae818b8 (patch)
treee291437527c024a28f9b16cf82689cc43ff43332 /src/arch
parentf6972a43581b24281b322a6f8d2bf02dafbe4433 (diff)
add timer-supported software i2c + arduino-nano timer
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/arduino-nano-168/Makefile.inc74
l---------src/arch/arduino-nano-168/arch.cc1
l---------src/arch/arduino-nano-168/driver1
-rw-r--r--src/arch/arduino-nano/Makefile.inc9
-rw-r--r--src/arch/arduino-nano/driver/timer.cc3
5 files changed, 88 insertions, 0 deletions
diff --git a/src/arch/arduino-nano-168/Makefile.inc b/src/arch/arduino-nano-168/Makefile.inc
new file mode 100644
index 0000000..de4ac8b
--- /dev/null
+++ b/src/arch/arduino-nano-168/Makefile.inc
@@ -0,0 +1,74 @@
+# vim:ft=make
+
+MCU = atmega168
+PORT = /dev/ttyUSB0
+BAUD = 19200
+
+COMMON_FLAGS += -Werror=overflow
+COMMON_FLAGS += -mmcu=${MCU} -DF_CPU=16000000UL -DMULTIPASS_ARCH_arduino_nano
+COMMON_FLAGS += -flto
+COMMON_FLAGS += -DMULTIPASS_ARCH_HAS_I2C
+
+CC = avr-gcc
+CXX = avr-g++
+NM = avr-nm
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+
+ifeq (${aspectc}, 1)
+ CXX = ag++ -r build/repo.acp -v 0 --c_compiler avr-g++ -p . --Xcompiler
+endif
+
+TARGETS += src/arch/arduino-nano/arch.cc
+TARGETS += src/arch/arduino-nano/driver/gpio.cc
+TARGETS += src/arch/arduino-nano/driver/stdout.cc
+TARGETS += src/arch/arduino-nano/driver/uptime.cc
+
+ifneq ($(findstring softi2c,${drivers}), )
+else ifneq ($(findstring i2c,${arch_drivers}), )
+ TARGETS += src/arch/arduino-nano/driver/i2c.cc
+endif
+
+ifneq ($(findstring stdin,${arch_drivers}), )
+ TARGETS += src/arch/arduino-nano/driver/stdin.cc
+endif
+
+ifneq ($(findstring timer,${arch_drivers}), )
+ TARGETS += src/arch/arduino-nano/driver/timer.cc
+endif
+
+ifneq (${i2c_freq}, )
+ COMMON_FLAGS += -DF_I2C=${i2c_freq}
+endif
+
+ifneq (${timer_freq}, )
+ COMMON_FLAGS += -DF_TIMER=${timer_freq}
+endif
+
+OBJECTS = ${TARGETS:.cc=.o}
+
+.cc.o:
+ ${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
+
+build/system.elf: ${OBJECTS}
+ ${CXX} ${COMMON_FLAGS} ${CXXFLAGS} -Wl,--gc-sections -o $@ ${OBJECTS}
+ avr-size --format=avr --mcu=${MCU} $@
+
+build/system.hex: build/system.elf
+ ${OBJCOPY} -O ihex ${@:.hex=.elf} $@
+
+program: build/system.hex
+ avrdude -p ${MCU} -c arduino -P ${PORT} -b ${BAUD} -U flash:w:build/system.hex
+
+arch_clean:
+ rm -f ${OBJECTS} build/system.hex
+
+monitor:
+ screen ${PORT} 115200
+
+arch_help:
+ @echo "arduino-nano specific flags:"
+ @echo " PORT = ${PORT}"
+ @echo " BAUD = ${BAUD} (only used for programming)"
+
+.PHONY: arch_clean arch_help monitor program
diff --git a/src/arch/arduino-nano-168/arch.cc b/src/arch/arduino-nano-168/arch.cc
new file mode 120000
index 0000000..808ad49
--- /dev/null
+++ b/src/arch/arduino-nano-168/arch.cc
@@ -0,0 +1 @@
+../arduino-nano/arch.cc \ No newline at end of file
diff --git a/src/arch/arduino-nano-168/driver b/src/arch/arduino-nano-168/driver
new file mode 120000
index 0000000..d402f72
--- /dev/null
+++ b/src/arch/arduino-nano-168/driver
@@ -0,0 +1 @@
+../arduino-nano/driver \ No newline at end of file
diff --git a/src/arch/arduino-nano/Makefile.inc b/src/arch/arduino-nano/Makefile.inc
index 18a6563..d4d5be7 100644
--- a/src/arch/arduino-nano/Makefile.inc
+++ b/src/arch/arduino-nano/Makefile.inc
@@ -4,6 +4,7 @@ MCU = atmega328p
PORT = /dev/ttyUSB0
BAUD = 57600
+COMMON_FLAGS += -Werror=overflow
COMMON_FLAGS += -mmcu=${MCU} -DF_CPU=16000000UL -DMULTIPASS_ARCH_arduino_nano
COMMON_FLAGS += -flto
COMMON_FLAGS += -DMULTIPASS_ARCH_HAS_I2C
@@ -32,10 +33,18 @@ ifneq ($(findstring stdin,${arch_drivers}), )
TARGETS += src/arch/arduino-nano/driver/stdin.cc
endif
+ifneq ($(findstring timer,${arch_drivers}), )
+ TARGETS += src/arch/arduino-nano/driver/timer.cc
+endif
+
ifneq (${i2c_freq}, )
COMMON_FLAGS += -DF_I2C=${i2c_freq}
endif
+ifneq (${timer_freq}, )
+ COMMON_FLAGS += -DF_TIMER=${timer_freq}
+endif
+
OBJECTS = ${TARGETS:.cc=.o}
.cc.o:
diff --git a/src/arch/arduino-nano/driver/timer.cc b/src/arch/arduino-nano/driver/timer.cc
new file mode 100644
index 0000000..4f2d6d1
--- /dev/null
+++ b/src/arch/arduino-nano/driver/timer.cc
@@ -0,0 +1,3 @@
+#include "driver/timer.h"
+
+Timer timer;