ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
hal.cpp
Go to the documentation of this file.
1#ifdef USE_RP2
2
3#include "core.h"
5#include "esphome/core/hal.h"
6#ifdef USE_RP2_CRASH_HANDLER
7#include "crash_handler.h"
8#endif
9
10#include "hardware/watchdog.h"
11
12// Empty rp2 namespace block to satisfy ci-custom's lint_namespace check.
13// HAL functions live in namespace esphome (root) — they are not part of the
14// rp2 component's API.
15namespace esphome::rp2 {} // namespace esphome::rp2
16
17namespace esphome {
18
19// yield(), delay(), micros(), millis(), millis_64(), delayMicroseconds(),
20// arch_feed_wdt(), arch_get_cpu_cycle_count() inlined in components/rp2/hal.h.
21void arch_restart() {
22 watchdog_reboot(0, 0, 10);
23 while (true) {
24 }
25}
26
27void arch_init() {
28#ifdef USE_RP2_CRASH_HANDLER
30#endif
31#if USE_RP2_WATCHDOG_TIMEOUT > 0
32 watchdog_enable(USE_RP2_WATCHDOG_TIMEOUT, false);
33#endif
34}
35
36uint32_t arch_get_cpu_freq_hz() { return RP2040::f_cpu(); }
37
38} // namespace esphome
39
40#endif // USE_RP2
void crash_handler_read_and_clear()
Read crash data from watchdog scratch registers and clear them.
void arch_init()
Definition hal.cpp:47
uint32_t arch_get_cpu_freq_hz()
Definition hal.cpp:63
void arch_restart()
Definition hal.cpp:39
static void uint32_t