Teensy 4.1 Architecture Definition

Whizz

New member
I need to detect the target architecture during compile within the Arduino or PlatformIO IDEs. Most target boards have a definition like ARDUINO_ARCH_XXXXX. Where XXXXX is the MCU. Some of the previous Teensy's have this defined (ARDUINO_ARCH_AVR - which I think maybe wrong as an additional issue), but not for the Teensy 4.1 in the TeensyDuino files. Is it defined anywhere, if not can it be added please?

Example:
#ifdef ARDUINO_ARCH_RP2040
#define rebootCore rp2040.restart
#endif

Cheers.
 
If you turn on verbose output during compile and look at the command line used, it has these when compiling for Teensy 4.0 using Arduino 1.8.19 and Teensyduino 1.60 (beta).

Code:
-D__IMXRT1062__ -DTEENSYDUINO=160 -DARDUINO=10819 -DARDUINO_TEENSY40

Hopefully some combination of these can meet your needs. Regarding "if not can it be added please?" the answer is Teensy has consistently used these defines for many years. Adding another is pretty unlikely to happen and wouldn't change the already published versions.

You also get some defines from the compiler's internals, like __arm__. Those are from the gcc toolchain, which we do sometimes update, though odds seem strong we'll stay with gcc 11.3 for at least another year or two.
 
"look at the command line used" Sorry, where do I find this command line? (Mac user here)

-jim lee
 
It is not really the command line used by you, but is the command line generated by Arduino to the compilers...

In this case there are several different things you can use to distinguish a Teensy.
Note the -D on the command line is something that is defined.

So for example: you can use: #ifdef __IMXRT1062__ This will include any board that uses an IMXRT1062, i.e Teensy 4.x
Also could test for: #ifdef TEENSYDUINO
And this will find all teensy boards.

For specific boards: #ifdef ARDUINO_TEENSY40
Will work for a Teensy 4, ARDUINO_TEENSY41 for 4.1

And use ARDUINO_TEENSY32 should get you there.

You can find out some of these defines if you look at boards.txt in the Teensy install like for the Micromod:
The line: teensyMM.build.board=TEENSY_MICROMOD
So to test for it you can try: #ifdef ARDUINO_TEENSY_MICROMOD
 
Thanks millions guys! really appreciate it!

#ifdef TEENSYDUINO sound like exactly what I was looking for.

-jim lee
 
Back
Top