aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Welter <michael@welter-4d.de>2017-02-04 16:15:13 +0100
committerMichael Welter <mw.pub@welter-4d.de>2017-02-12 11:22:36 +0100
commitc6012a4be50a2d89cbf06deb4376aefc339d7fe8 (patch)
tree8e89498307c216a89cd98cf52fd288ef9d1c72e9
parent12522f3726f11ed884d3ebb0bf22650f707b0fb1 (diff)
Autodetect the fastest speed with which various Teensy boards can run. Alternatively, set the speed in MHz via BOARD_SUB.
-rw-r--r--Teensy.mk15
1 files changed, 12 insertions, 3 deletions
diff --git a/Teensy.mk b/Teensy.mk
index 1d72976..8bd822b 100644
--- a/Teensy.mk
+++ b/Teensy.mk
@@ -37,15 +37,24 @@ ARDMK_VENDOR = teensy
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt
-ifndef F_CPU
- F_CPU=96000000
-endif
ifndef PARSE_TEENSY
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_TEENSY = $(shell grep -v "^\#" "$(BOARDS_TXT)" | grep $(1).$(2) | cut -d = -f 2- )
endif
+
+ifndef F_CPU
+ ifndef BOARD_SUB
+ SPEEDS := $(call PARSE_TEENSY,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies.
+ SPEEDS := $(shell printf "%d\n" $(SPEEDS) | sort -g) # Sort it, just in case. Printf to re-append newlines so that sort works.
+ F_CPU := $(lastword $(SPEEDS)) # List is sorted in ascending order. Take the fastest speed.
+ #$(info "speeds is " $(SPEEDS)) # Good for debugging
+ else
+ F_CPU := $(call PARSE_TEENSY,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu)
+ endif
+endif
+
# if boards.txt gets modified, look there, else hard code it
ARCHITECTURE = $(call PARSE_TEENSY,$(BOARD_TAG),build.architecture)
ifeq ($(strip $(ARCHITECTURE)),)