[rp2040] Allow changing watchdog timeout (#8868)

This commit is contained in:
Kuba Szczodrzyński 2025-05-29 07:15:26 +02:00 committed by GitHub
parent 0b1c5b825e
commit 20aba45cbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 2 deletions

View File

@ -10,6 +10,7 @@ from esphome.const import (
CONF_TIMEOUT,
CONF_TRIGGER_ID,
CONF_URL,
CONF_WATCHDOG_TIMEOUT,
PLATFORM_HOST,
__version__,
)
@ -43,7 +44,6 @@ CONF_USERAGENT = "useragent"
CONF_VERIFY_SSL = "verify_ssl"
CONF_FOLLOW_REDIRECTS = "follow_redirects"
CONF_REDIRECT_LIMIT = "redirect_limit"
CONF_WATCHDOG_TIMEOUT = "watchdog_timeout"
CONF_BUFFER_SIZE_RX = "buffer_size_rx"
CONF_BUFFER_SIZE_TX = "buffer_size_tx"
CONF_CA_CERTIFICATE_PATH = "ca_certificate_path"

View File

@ -10,6 +10,7 @@ from esphome.const import (
CONF_PLATFORM_VERSION,
CONF_SOURCE,
CONF_VERSION,
CONF_WATCHDOG_TIMEOUT,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
KEY_TARGET_FRAMEWORK,
@ -147,6 +148,10 @@ CONFIG_SCHEMA = cv.All(
{
cv.Required(CONF_BOARD): cv.string_strict,
cv.Optional(CONF_FRAMEWORK, default={}): ARDUINO_FRAMEWORK_SCHEMA,
cv.Optional(CONF_WATCHDOG_TIMEOUT, default="8388ms"): cv.All(
cv.positive_time_period_milliseconds,
cv.Range(max=cv.TimePeriod(milliseconds=8388)),
),
}
),
set_core_data,
@ -189,6 +194,8 @@ async def to_code(config):
cg.RawExpression(f"VERSION_CODE({ver.major}, {ver.minor}, {ver.patch})"),
)
cg.add_define("USE_RP2040_WATCHDOG_TIMEOUT", config[CONF_WATCHDOG_TIMEOUT])
def add_pio_file(component: str, key: str, data: str):
try:

View File

@ -1,6 +1,7 @@
#ifdef USE_RP2040
#include "core.h"
#include "esphome/core/defines.h"
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
@ -19,7 +20,13 @@ void arch_restart() {
continue;
}
}
void arch_init() { watchdog_enable(0x7fffff, false); }
void arch_init() {
#if USE_RP2040_WATCHDOG_TIMEOUT > 0
watchdog_enable(USE_RP2040_WATCHDOG_TIMEOUT, false);
#endif
}
void IRAM_ATTR HOT arch_feed_wdt() { watchdog_update(); }
uint8_t progmem_read_byte(const uint8_t *addr) {

View File

@ -963,6 +963,7 @@ CONF_WAND_ID = "wand_id"
CONF_WARM_WHITE = "warm_white"
CONF_WARM_WHITE_COLOR_TEMPERATURE = "warm_white_color_temperature"
CONF_WATCHDOG_THRESHOLD = "watchdog_threshold"
CONF_WATCHDOG_TIMEOUT = "watchdog_timeout"
CONF_WEB_SERVER = "web_server"
CONF_WEB_SERVER_ID = "web_server_id"
CONF_WEIGHT = "weight"