Skip to content

Commit cf75047

Browse files
committed
Add ESP.getCoreVersion() and update ESP.getChipModel()
1 parent d059d43 commit cf75047

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

cores/esp32/Esp.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ uint32_t EspClass::getFreeSketchSpace () {
258258
return _partition->size;
259259
}
260260

261-
uint8_t EspClass::getChipRevision(void)
261+
uint16_t EspClass::getChipRevision(void)
262262
{
263263
esp_chip_info_t chip_info;
264264
esp_chip_info(&chip_info);
@@ -306,10 +306,18 @@ const char * EspClass::getChipModel(void)
306306
default:
307307
return "ESP32-S2 (Unknown)";
308308
}
309-
#elif CONFIG_IDF_TARGET_ESP32S3
310-
return "ESP32-S3";
311-
#elif CONFIG_IDF_TARGET_ESP32C3
312-
return "ESP32-C3";
309+
#else
310+
esp_chip_info_t chip_info;
311+
esp_chip_info(&chip_info);
312+
switch(chip_info.model){
313+
case CHIP_ESP32S3: return "ESP32-S3";
314+
case CHIP_ESP32C3: return "ESP32-C3";
315+
case CHIP_ESP32H4: return "ESP32-H4";
316+
case CHIP_ESP32C2: return "ESP32-C2";
317+
case CHIP_ESP32C6: return "ESP32-C6";
318+
case CHIP_ESP32H2: return "ESP32-H2";
319+
default: return "UNKNOWN";
320+
}
313321
#endif
314322
}
315323

@@ -325,6 +333,11 @@ const char * EspClass::getSdkVersion(void)
325333
return esp_get_idf_version();
326334
}
327335

336+
const char * EspClass::getCoreVersion(void)
337+
{
338+
return ESP_ARDUINO_VERSION_STR;
339+
}
340+
328341
uint32_t ESP_getFlashChipId(void)
329342
{
330343
uint32_t id = g_rom_flashchip.device_id;

cores/esp32/Esp.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ class EspClass
7777
uint32_t getMinFreePsram();
7878
uint32_t getMaxAllocPsram();
7979

80-
uint8_t getChipRevision();
80+
uint16_t getChipRevision();
8181
const char * getChipModel();
8282
uint8_t getChipCores();
8383
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
8484
inline uint32_t getCycleCount() __attribute__((always_inline));
85-
const char * getSdkVersion();
85+
86+
const char * getSdkVersion(); //version of ESP-IDF
87+
const char * getCoreVersion();//version of this core
8688

8789
void deepSleep(uint32_t time_us);
8890

cores/esp32/esp_arduino_version.h

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ extern "C" {
4141
ESP_ARDUINO_VERSION_MINOR, \
4242
ESP_ARDUINO_VERSION_PATCH)
4343

44+
/**
45+
* Current ARDUINO version, as string
46+
*/
47+
#define df2xstr(s) #s
48+
#define df2str(s) df2xstr(s)
49+
#define ESP_ARDUINO_VERSION_STR df2str(ESP_ARDUINO_VERSION_MAJOR) "." df2str(ESP_ARDUINO_VERSION_MINOR) "." df2str(ESP_ARDUINO_VERSION_PATCH)
50+
4451
#ifdef __cplusplus
4552
}
4653
#endif

0 commit comments

Comments
 (0)