Controller specific defines for STM

Post here first, or if you can't find a relevant section!
Post Reply
moelski
Posts: 7
Joined: Mon Jan 18, 2021 5:15 am

Controller specific defines for STM

Post by moelski »

Hello again,

I´d like to port some code which uses prcocessor specific defines like this ones:
__AVR_ATmega328P__ > AVR Mega 328
ESP8266 > ESP8266
__IMXRT1062__, ARDUINO_TEENSY41 > some Teensy boards

Which defines can I use when working with the STM32?
And can anyone tell me where I can find those defines? So I could search by myself.

For Arduino as an example I can find them in the gcc / Device-Specs Folder.

Dominik
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Controller specific defines for STM

Post by fpiSTM »

For the core:

Code: Select all

ARDUINO_ARCH_STM32
For STM32 series:

Code: Select all

STM32YYxx
where YY is the family, example for L4:

Code: Select all

STM32L4xx
For specific product line:

Code: Select all

STM32L452xx
You can find all product line in this file: https://github.com/stm32duino/Arduino_C ... ef_build.h

Finally you can also use specific cortex definition like it is done here: https://github.com/stm32duino/STM32Free ... ortmacro.h

Code: Select all

#ifndef __CORTEX_M
#pragma GCC error  "no \"__CORTEX_M\" definition"
#endif

#if (__CORTEX_M == 0x00U)
#include "../portable/GCC/ARM_CM0/portmacro.h"
#endif
moelski
Posts: 7
Joined: Mon Jan 18, 2021 5:15 am

Re: Controller specific defines for STM

Post by moelski »

Again. Many thx for your help.
This helps alot.

Dominik
moelski
Posts: 7
Joined: Mon Jan 18, 2021 5:15 am

Re: Controller specific defines for STM

Post by moelski »

One additional question ...

Is it possible to have that in some print statement?
Something like

Code: Select all

Serial.Print("arch : "); Serial.Println(??ARCH??)
Post Reply

Return to “General discussion”