Build macro to identify chip

Kaisha
Posts: 42
Joined: Thu Mar 05, 2020 8:59 pm

Build macro to identify chip

Postby Kaisha » Mon Feb 14, 2022 1:20 pm

Is there a macro to identify which chip an application if being built for. Something like 'ESP32' or 'ESP32s3'??

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Build macro to identify chip

Postby ESP_Sprite » Tue Feb 15, 2022 1:35 am

If you include sdkconfig.h, you can either use the CONFIG_IDF_TARGET_* defines to check for a chip (e.g. #if CONFIG_IDF_TARGET_ESP32) or use CONFIG_IDF_TARGET to get a string representation.

Kaisha
Posts: 42
Joined: Thu Mar 05, 2020 8:59 pm

Re: Build macro to identify chip

Postby Kaisha » Tue Feb 15, 2022 12:51 pm

Is there a list of CONFIG_IDF_TARGET_ESP32 defines for other chips (like s3, 8266, etc...)?

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Build macro to identify chip

Postby ESP_Sprite » Wed Feb 16, 2022 3:25 am

esp-idf/Kconfig has them listed out. (Note that Kconfig files leave off the CONFIG_ bit, so e.g. the ESP32S2 target is called IDF_TARGET_ESP32S2)

Who is online

Users browsing this forum: Baidu [Spider], Bryght-Richard and 217 guests