Using Teensy 4.1 without Arduino

MickPF

Member
Hello,

I'd like to use Teensy 4.1 without Arduino (I hate this C++) only with the C compiler.

Are there any instructions or guides on this?
Is it possible to use the peripherals (I2C, SPI, etc.) in this environment as simply as possible (as under Linux or as in ESP-IDF)?

Kind Regards,
Michael
 
Look for the sample makefile in {Arduino}/hardware/teensy/avr/cores/teensy4.

If you're using Teensyduino 1.53 or earlier, you might want to install the latest beta. The makefile was originally made for Teensy 4.0. The new beta have an updated makefile.

https://forum.pjrc.com/threads/64303-Teensyduino-1-54-Beta-4

This will let you build from the command line without using Arduino.

But the code is a mix of C and C++. Most of the lowest level code is all in C, so with some work you could probably replace the C++ or just delete it and call the C functions directly, if you're able to read the code and figure out how they're used.

Many of the libraries are only in C++. But even with those libraries, very few of the special C++ features are actually used, so with some effort you could probably rewrite the functions to be ordinary C. How you would do that is a matter of personal preference. But the way I've seen other systems implement C-only "drivers" for hardware ports always involves a struct which defines the specific port and data needed specifically for that port (like a buffer and head & tail index), where you pass a pointer to that port-specific instance into every function.... which is exactly what C++ does.

Anyway, however you choose to write your code, hopefully the sample makefile will give you a non-Arduino path forward?
 
Back
Top