ESPHome 2026.7.0
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 (1) {
24 continue;
25 }
26}
27
28void arch_init() {
29#ifdef USE_RP2_CRASH_HANDLER
31#endif
32#if USE_RP2_WATCHDOG_TIMEOUT > 0
33 watchdog_enable(USE_RP2_WATCHDOG_TIMEOUT, false);
34#endif
35}
36
37uint32_t arch_get_cpu_freq_hz() { return RP2040::f_cpu(); }
38
39} // namespace esphome
40
41#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