Unverified Commit 7e9d42da authored by Martijn Scheepers's avatar Martijn Scheepers Committed by GitHub

ESP.getChipModel() and ESP.getChipCores() (#3847)

* ESP.getChipModel() returns model of the chip

* ESP.getChipCores() returns the core count.

* Example gives chip model, revision and core count.

* Read efuse for chipmodel
Co-authored-by: default avatarMartijn Scheepers <ms@SDNengineering.nl>
parent e34e0b45
......@@ -218,6 +218,33 @@ uint8_t EspClass::getChipRevision(void)
return chip_info.revision;
}
const char * EspClass::getChipModel(void)
{
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
uint32_t pkg_ver = chip_ver & 0x7;
switch (pkg_ver) {
case EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ6 :
return "ESP32-D0WDQ6";
case EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ5 :
return "ESP32-D0WDQ5";
case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 :
return "ESP32-D2WDQ5";
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 :
return "ESP32-PICO-D2";
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 :
return "ESP32-PICO-D4";
default:
return "Unknown";
}
}
uint8_t EspClass::getChipCores(void)
{
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
return chip_info.cores;
}
const char * EspClass::getSdkVersion(void)
{
return esp_get_idf_version();
......
......@@ -75,6 +75,8 @@ public:
uint32_t getMaxAllocPsram();
uint8_t getChipRevision();
const char * getChipModel();
uint8_t getChipCores();
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
inline uint32_t getCycleCount() __attribute__((always_inline));
const char * getSdkVersion();
......
......@@ -9,6 +9,9 @@ void loop() {
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
Serial.printf("This chip has %d cores\n", ESP.getChipCores());
delay(3000);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment