summaryrefslogtreecommitdiff
path: root/src/arch/arduino-nano-168
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-10-19 09:01:36 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-10-19 09:01:36 +0200
commit255085d06a75c424cd6b95aaac10056e5de65876 (patch)
tree345a6bb1772089e4928e88f5035648f82b51531e /src/arch/arduino-nano-168
parent458c89d71c3aa22eb5e83d4e34930a8978c0ef7e (diff)
arduino nano: support additional CPU frequencies
Diffstat (limited to 'src/arch/arduino-nano-168')
-rw-r--r--src/arch/arduino-nano-168/Makefile.inc29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/arch/arduino-nano-168/Makefile.inc b/src/arch/arduino-nano-168/Makefile.inc
index 534ac27..a56e62a 100644
--- a/src/arch/arduino-nano-168/Makefile.inc
+++ b/src/arch/arduino-nano-168/Makefile.inc
@@ -7,7 +7,8 @@ BAUD = 19200
cpu_freq ?= 16000000
COMMON_FLAGS += -Werror=overflow
-COMMON_FLAGS += -mmcu=${MCU} -DF_CPU=16000000UL -DMULTIPASS_ARCH_arduino_nano
+COMMON_FLAGS += -mmcu=${MCU} -DMULTIPASS_ARCH_arduino_nano
+COMMON_FLAGS += -DF_CPU=${cpu_freq}UL
COMMON_FLAGS += -flto
COMMON_FLAGS += -DMULTIPASS_ARCH_HAS_I2C
@@ -39,6 +40,30 @@ ifneq ($(findstring timer,${arch_drivers}), )
TARGETS += src/arch/arduino-nano/driver/timer.cc
endif
+ifeq (${cpu_freq}, 16000000)
+ uart_baud = 57600
+else ifeq (${cpu_freq}, 8000000)
+ uart_baud = 38400
+else ifeq (${cpu_freq}, 4000000)
+ uart_baud = 38400
+else ifeq (${cpu_freq}, 2000000)
+ uart_baud = 19200
+else ifeq (${cpu_freq}, 1000000)
+ uart_baud = 9600
+else ifeq (${cpu_freq}, 500000)
+ uart_baud = 4800
+else ifeq (${cpu_freq}, 250000)
+ uart_baud = 2400
+else ifeq (${cpu_freq}, 125000)
+ uart_baud = 1200
+else ifeq (${cpu_freq}, 62500)
+ uart_baud = 300
+else
+ uart_baud = 9600
+endif
+
+COMMON_FLAGS += -DBAUD=${uart_baud}UL
+
OBJECTS = ${TARGETS:.cc=.o}
.cc.o:
@@ -58,7 +83,7 @@ arch_clean:
${QUIET}rm -f ${OBJECTS} build/system.hex
monitor:
- ${QUIET}screen ${PORT} 115200
+ ${QUIET}screen ${PORT} ${uart_baud}
arch_help:
@echo "arduino-nano specific flags:"