Skip to content

Commit c6012a4

Browse files
DaWelterDaMichel
authored andcommitted
Autodetect the fastest speed with which various Teensy boards can run. Alternatively, set the speed in MHz via BOARD_SUB.
1 parent 12522f3 commit c6012a4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Teensy.mk

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,24 @@ ARDMK_VENDOR = teensy
3737
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3
3838
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt
3939

40-
ifndef F_CPU
41-
F_CPU=96000000
42-
endif
4340

4441
ifndef PARSE_TEENSY
4542
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
4643
PARSE_TEENSY = $(shell grep -v "^\#" "$(BOARDS_TXT)" | grep $(1).$(2) | cut -d = -f 2- )
4744
endif
4845

46+
47+
ifndef F_CPU
48+
ifndef BOARD_SUB
49+
SPEEDS := $(call PARSE_TEENSY,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies.
50+
SPEEDS := $(shell printf "%d\n" $(SPEEDS) | sort -g) # Sort it, just in case. Printf to re-append newlines so that sort works.
51+
F_CPU := $(lastword $(SPEEDS)) # List is sorted in ascending order. Take the fastest speed.
52+
#$(info "speeds is " $(SPEEDS)) # Good for debugging
53+
else
54+
F_CPU := $(call PARSE_TEENSY,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu)
55+
endif
56+
endif
57+
4958
# if boards.txt gets modified, look there, else hard code it
5059
ARCHITECTURE = $(call PARSE_TEENSY,$(BOARD_TAG),build.architecture)
5160
ifeq ($(strip $(ARCHITECTURE)),)

0 commit comments

Comments
 (0)