diff --git a/esphome/components/zephyr/core.cpp b/esphome/components/zephyr/core.cpp index cac9be45b5..3f44ecdb4b 100644 --- a/esphome/components/zephyr/core.cpp +++ b/esphome/components/zephyr/core.cpp @@ -6,8 +6,8 @@ namespace esphome { -static int wdt_channel_id = -EINVAL; -const device *wdt = nullptr; +static int wdt_channel_id = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +static const device *const WDT = DEVICE_DT_GET(DT_ALIAS(watchdog0)); void yield() { ::k_yield(); } uint32_t millis() { return k_ticks_to_ms_floor32(k_uptime_ticks()); } @@ -16,22 +16,20 @@ void delayMicroseconds(uint32_t us) { ::k_usleep(us); } void delay(uint32_t ms) { ::k_msleep(ms); } void arch_init() { - wdt = DEVICE_DT_GET(DT_ALIAS(watchdog0)); - - if (device_is_ready(wdt)) { + if (device_is_ready(WDT)) { static wdt_timeout_cfg wdt_config{}; wdt_config.flags = WDT_FLAG_RESET_SOC; wdt_config.window.max = 2000; - wdt_channel_id = wdt_install_timeout(wdt, &wdt_config); + wdt_channel_id = wdt_install_timeout(WDT, &wdt_config); if (wdt_channel_id >= 0) { - wdt_setup(wdt, WDT_OPT_PAUSE_HALTED_BY_DBG | WDT_OPT_PAUSE_IN_SLEEP); + wdt_setup(WDT, WDT_OPT_PAUSE_HALTED_BY_DBG | WDT_OPT_PAUSE_IN_SLEEP); } } } void arch_feed_wdt() { if (wdt_channel_id >= 0) { - wdt_feed(wdt, wdt_channel_id); + wdt_feed(WDT, wdt_channel_id); } } diff --git a/esphome/core/gpio.h b/esphome/core/gpio.h index b3f6b00196..0492c71792 100644 --- a/esphome/core/gpio.h +++ b/esphome/core/gpio.h @@ -78,7 +78,7 @@ class NullPin : public GPIOPin { std::string dump_summary() const override { return {"Not used"}; } }; -static GPIOPin *const NULL_PIN = new NullPin(); +static const GPIOPin *const NULL_PIN = new NullPin(); /// Copy of GPIOPin that is safe to use from ISRs (with no virtual functions) class ISRInternalGPIOPin { diff --git a/script/helpers.py b/script/helpers.py index 24166960a2..27be1aa35d 100644 --- a/script/helpers.py +++ b/script/helpers.py @@ -181,7 +181,8 @@ int main() { return 0;} defines = [] define_pattern = re.compile(r"-D\s*([^\s]+)") for match in define_pattern.findall(command): - defines.append(match) + if match not in ("_ASMLANGUAGE"): + defines.append(match) return defines def find_cxx_path(commands):