ESPHome 2026.8.1
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/clocks.h"
11#include "hardware/watchdog.h"
12
13// Empty rp2 namespace block to satisfy ci-custom's lint_namespace check.
14// HAL functions live in namespace esphome (root) — they are not part of the
15// rp2 component's API.
16namespace esphome::rp2 {} // namespace esphome::rp2
17
18namespace esphome {
19
20// yield(), delay(), micros(), millis(), millis_64(), delayMicroseconds(),
21// arch_feed_wdt(), arch_get_cpu_cycle_count() inlined in components/rp2/hal.h.
22void arch_restart() {
23 watchdog_reboot(0, 0, 10);
24 while (true) {
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
37// clock_get_hz(clk_sys) is the SDK query for the current system clock frequency in Hz.
38uint32_t arch_get_cpu_freq_hz() { return clock_get_hz(clk_sys); }
39
40} // namespace esphome
41
42#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