fix clang-tidy

This commit is contained in:
Tomasz Duda 2024-07-24 14:39:26 +02:00
parent 508468a031
commit dd43acf7af
3 changed files with 9 additions and 10 deletions

View file

@ -6,8 +6,8 @@
namespace esphome { namespace esphome {
static int wdt_channel_id = -EINVAL; static int wdt_channel_id = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
const device *wdt = nullptr; static const device *const WDT = DEVICE_DT_GET(DT_ALIAS(watchdog0));
void yield() { ::k_yield(); } void yield() { ::k_yield(); }
uint32_t millis() { return k_ticks_to_ms_floor32(k_uptime_ticks()); } 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 delay(uint32_t ms) { ::k_msleep(ms); }
void arch_init() { 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{}; static wdt_timeout_cfg wdt_config{};
wdt_config.flags = WDT_FLAG_RESET_SOC; wdt_config.flags = WDT_FLAG_RESET_SOC;
wdt_config.window.max = 2000; 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) { 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() { void arch_feed_wdt() {
if (wdt_channel_id >= 0) { if (wdt_channel_id >= 0) {
wdt_feed(wdt, wdt_channel_id); wdt_feed(WDT, wdt_channel_id);
} }
} }

View file

@ -78,7 +78,7 @@ class NullPin : public GPIOPin {
std::string dump_summary() const override { return {"Not used"}; } 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) /// Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
class ISRInternalGPIOPin { class ISRInternalGPIOPin {

View file

@ -181,6 +181,7 @@ int main() { return 0;}
defines = [] defines = []
define_pattern = re.compile(r"-D\s*([^\s]+)") define_pattern = re.compile(r"-D\s*([^\s]+)")
for match in define_pattern.findall(command): for match in define_pattern.findall(command):
if match not in ("_ASMLANGUAGE"):
defines.append(match) defines.append(match)
return defines return defines