From fc3d558d479ec4a3a7a8118979b4bee92d4d2cfc Mon Sep 17 00:00:00 2001 From: Jimmy Hedman Date: Wed, 5 Jul 2023 00:28:12 +0200 Subject: [PATCH] Initial debug component support for rp2040 (#5056) --- esphome/components/debug/__init__.py | 1 - esphome/components/debug/debug_component.cpp | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/esphome/components/debug/__init__.py b/esphome/components/debug/__init__.py index 9742b3b19e..1955b5d22c 100644 --- a/esphome/components/debug/__init__.py +++ b/esphome/components/debug/__init__.py @@ -38,7 +38,6 @@ CONFIG_SCHEMA = cv.All( ), } ).extend(cv.polling_component_schema("60s")), - cv.only_on(["esp32", "esp8266"]), ) diff --git a/esphome/components/debug/debug_component.cpp b/esphome/components/debug/debug_component.cpp index 9b7e256147..8b6a97068b 100644 --- a/esphome/components/debug/debug_component.cpp +++ b/esphome/components/debug/debug_component.cpp @@ -22,8 +22,12 @@ #endif // USE_ESP32 #ifdef USE_ARDUINO +#ifdef USE_RP2040 +#include +#else #include #endif +#endif namespace esphome { namespace debug { @@ -35,6 +39,8 @@ static uint32_t get_free_heap() { return ESP.getFreeHeap(); // NOLINT(readability-static-accessed-through-instance) #elif defined(USE_ESP32) return heap_caps_get_free_size(MALLOC_CAP_INTERNAL); +#elif defined(USE_RP2040) + return rp2040.getFreeHeap(); #endif } @@ -65,7 +71,7 @@ void DebugComponent::dump_config() { this->free_heap_ = get_free_heap(); ESP_LOGD(TAG, "Free Heap Size: %" PRIu32 " bytes", this->free_heap_); -#ifdef USE_ARDUINO +#if defined(USE_ARDUINO) && !defined(USE_RP2040) const char *flash_mode; switch (ESP.getFlashChipMode()) { // NOLINT(readability-static-accessed-through-instance) case FM_QIO: @@ -274,6 +280,11 @@ void DebugComponent::dump_config() { reset_reason = ESP.getResetReason().c_str(); #endif +#ifdef USE_RP2040 + ESP_LOGD(TAG, "CPU Frequency: %u", rp2040.f_cpu()); + device_info += "CPU Frequency: " + to_string(rp2040.f_cpu()); +#endif // USE_RP2040 + #ifdef USE_TEXT_SENSOR if (this->device_info_ != nullptr) { if (device_info.length() > 255)