Skip to content
/ teensy-template Public template

A Teensy 3.x/4.x project template inspired by apmorton/teensy-template and referencing cores from PaulStoffregen/cores

Notifications You must be signed in to change notification settings

rspurrell/teensy-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teensy 3.x/4.x Project Template

A comprehensive Teensy 3.x/4.x project template for Linux, Windows Subsystem for Linux (WSL), and Windows. Inspired by apmorton/teensy-template referencing the Teensy cores from PaulStoffregen/cores. Configurations for VS Code are included, but not required to use this project template.

Tools Setup

After cloning this project you'll need the appropriate tools for your OS to compile and upload your code to your Teensy. You have two options (for WSL you must install Teensyduino for Windows from option 2 regardless of which tools option you choose):

Option 1. Subtree the Standalone Teensy Tools from this Repository

Enables your project to compile standalone, but increases your project size. Run these two Git commands from the terminal within your project:

  1. git remote add tools https://github.com/rspurrell/teensy-template.git
  2. Then either:
    • Linux/WSL: git subtree add --squash --prefix=tools/ tools linux-tools
    • Windows: git subtree add --squash --prefix=tools/ tools windows-tools

Option 2. Install Arduino and Teensyduino

Consumes a smaller footprint, but has a dependency on having Teensyduino installed to compile.

Linux/WSL

  1. Download and extract an Arduino IDE tarball:
wget https://downloads.arduino.cc/arduino-1.8.13-linux64.tar.xz
tar xvf arduino-1.8.13-linux64.tar.xz -C /path/to/parent
  1. Download and install Teensyduino:
wget https://www.pjrc.com/teensy/td_153/TeensyduinoInstall.linux64
chmod 755 TeensyduinoInstall.linux64
./TeensyduinoInstall.linux64 --dir=/path/to/parent/arduino-1.8.13

WSL/Windows

  1. Install the Arduino IDE
  2. Install Teensyduino for Windows

Environment Setup

Linux

  1. Install the Teensy udev rule: sudo cp 49-teensy.rules /etc/udev/rules.d/
  2. Unplug your Teensy and plug it back in

WSL

Create a convenient shortcut to the Teensy loader executable at %PROGRAMFILES(x86)%\Arduino\hardware\tools\teensy.exe.

Please note that since there is no USB support in WSL, make upload will not work.

Windows

Install GNU Make for Windows. I highly recommended using the Windows package manager, Chocolately. Once installed, simply type choco install make on an elevated command line.

Using the Template

  1. Put your code in src/main.cpp and its folder
  2. Put any libraries you need in libraries
  3. Set the TEENSY variable in Makefile according to your teensy version
    • You may need to update the TOOLSPATH variable depending what you choose for your tools setup
  4. Build your code make. Alternatively, use make TEENSY=** where ** is your Teensy version [LC, 30, 31, 32, 35, 36, 40, 41]
  5. Upload your code:
    • Linux/Windows: make upload (does not work with WSL)
    • WSL: Using Teensy loader, locate and load the compiled hex file located in your WSL project folder. (eg. \\wsl$\Ubuntu-20.04\home\rspurrell\workspaces\teensy\teensy-template\bin)

Using VS Code

  1. Install the Microsoft C/C++ Extensions
  2. Open this project folder in VS Code
  3. Adjust the toolsPath and compilerPath in .vscode/c_cpp_properties.json as necessary
  4. Select the configuration matching your Teensy. Ctrl+Shift+P and type Select a Configuration

References

  • The cores sub-folder is a git subtree of PaulStoffregen/cores
  • The linux-tool and windows-tools branches are taken from Teensyduino v1.5.3
  • The src/main.cpp file is a copy of teensy4/main.cpp
  • The Makefile file is a modified copy of teensy3/Makefile
  • The 49-teensy.rules file is taken from PJRC's udev rules
  • Inspiration for this template was appropriated from apmorton/teensy-template

About

A Teensy 3.x/4.x project template inspired by apmorton/teensy-template and referencing cores from PaulStoffregen/cores

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages