platformio.ini for Teensy 4.1

maregi5

New member
I started using PlatformIO with Teensy but couldn't find an easy all-in-one reference for the options that in Arduino IDE you can select from the menu (CPU speed, USB type, optimization and keyboard layout), so I wrote one myself.
The below example should work as reference how one could set the corresponding options using platformio.ini.
Haven't tested it much so if there are some mistakes please correct.


Code:
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
upload_protocol = teensy-gui 
                ; teensy-gui | teensy-cli

; --CPU speed (Hz)--
board_build.f_cpu = 528000000L 
                  ; 600000000 | 528000000 | 450000000 | 396000000 | 150000000 | 24000000 | 720000000 | 816000000 | 912000000 | 960000000 | 1008000000
                  ; CAUTION! 600000000 is the default option. Options higher than it are considered overclocking, and options higher than 816000000 REQUIRE ADDITIONAL COOLING!
                  ; (from Teensyduino Arduino IDE: .arduino15/packages/teensy/hardware/avr/1.58.0/boards.txt)


build_flags = 
; --USB type--
              -D USB_SERIAL 
               ; USB_SERIAL | USB_DUAL_SERIAL | USB_TRIPLE_SERIAL | USB_KEYBOARDONLY | USB_TOUCHSCREEN | USB_HID_TOUCHSCREEN | USB_HID | USB_SERIAL_HID | USB_MIDI | USB_MIDI4 | USB_MIDI16 | USB_MIDI_SERIAL | USB_MIDI4_SERIAL | USB_MIDI16_SERIAL | USB_AUDIO | USB_MIDI_AUDIO_SERIAL | USB_MIDI16_AUDIO_SERIAL | USB_MTPDISK | USB_MTPDISK_SERIAL | USB_RAWHID | USB_FLIGHTSIM | USB_FLIGHTSIM_JOYSTICK
               ; (from PlatformIO: framework-arduinoteensy/cores/teensy4/usb_desc.h and Teensyduino Arduino IDE: .arduino15/packages/teensy/hardware/avr/1.58.0/boards.txt)

; --Code optimization--
              -D TEENSY_OPT_FASTER 
               ; TEENSY_OPT_FASTER | TEENSY_OPT_FAST | TEENSY_OPT_FASTEST | TEENSY_OPT_DEBUG | TEENSY_OPT_SMALLEST_CODE
               ; (see Teensyduino Arduino IDE: .arduino15/packages/teensy/hardware/avr/1.58.0/boards.txt and https://github.com/platformio/platform-teensy/blob/develop/builder/frameworks/arduino.py)

; --Keyboard layout--
              -D LAYOUT_US_ENGLISH 
               ; LAYOUT_US_ENGLISH | LAYOUT_CANADIAN_FRENCH | LAYOUT_CANADIAN_MULTILINGUAL | LAYOUT_CZECH | ...(search framework-arduinoteensy/cores/teensy4/keylayouts.h for the rest of the layout options)
 
Back
Top