queezythegreat / arduino-cmake

Arduino CMake Build system
645 stars 216 forks source link

Teensy Compatibility #142

Open dave-newson opened 9 years ago

dave-newson commented 9 years ago

Following on from issue https://github.com/queezythegreat/arduino-cmake/issues/67, this PR adds support for Teensy boards and the Teensy SDK for arduino-cmake. The crux of this PR is adding additional compile options and detecting/using teensy_loader_cli (halfkay) over avrdude for uploading.

Teensy-specific board modes that are available (usually speed, usb and keys) can be listed using the following command: print_teensy_modes(board_id) where board_id is the specific Teensy board identifier. The options available for each mode can be viewed using: print_teensy_modes(board_id MODE mode_id) where mode_id is the mode (eg. speed) you want to view options for.

Three specific options must be set for the Teensy board to compile correctly: set(TEENSY_CPU_F_MODE 16) set(TEENSY_USB_MODE serial) set(TEENSY_KEYBOARD_MODE en-us)

If the Teensy board is detected (usually specified in the Teensy boards.txt config via the <board_id>.upload.protocol value as halfkay), the teensy_loader_cli will be used. All other options (or null) default to avrdude, as before.

Some additional support for teensy-specific build flags has been added, allowing <board_id>.build.optionX definitions to be imported from the the boards.txt file as compile flags.

Failing to define a F_CPU will now also raise a fatal error. This is a common hiccup when trying to set up arduino-cmake with a Teensy.

Requires (and integrates) PRs https://github.com/queezythegreat/arduino-cmake/pull/141 and https://github.com/queezythegreat/arduino-cmake/pull/140.

Please note I only have a Teensy, so I haven't been able to thoroughly test this against standard arduino boards.

filosganga commented 9 years ago

What about this PR? would really like see it merged.

dave-newson commented 9 years ago

@filosganga iirc I ran into some problems with this and compiling out to Teensy 3. Does work with Teensy 2++, mind you, so it's at least a step in the right direction.

filosganga commented 9 years ago

thanks

dave-newson commented 8 years ago

For what it's worth to anyone else who happens across this PR, I've abandoned trying to make this work in favor of using PlatformIO for the same cross-OS compiling. There were too many variables with the Teensy3 for me to understand, which they seem to have resolved.

Will leave this PR open, but I now feel it's incomplete. I'll leave it up to the project maintainer to decide its fate.