6#include <hardware/watchdog.h>
7#if defined(PICO_RP2350)
8#include <hardware/structs/powman.h>
10#include <hardware/structs/vreg_and_chip_reset.h>
12#ifdef USE_RP2040_CRASH_HANDLER
18static const char *
const TAG =
"debug";
21 char *buf = buffer.data();
22 const size_t size = RESET_REASON_BUFFER_SIZE;
25#if defined(PICO_RP2350)
26 uint32_t chip_reset = powman_hw->chip_reset;
27 if (chip_reset & 0x04000000)
29 if (chip_reset & 0x00040000)
31 if (chip_reset & 0x00020000)
33 if (chip_reset & 0x00010000)
36 uint32_t chip_reset = vreg_and_chip_reset_hw->chip_reset;
37 if (chip_reset & 0x00010000)
39 if (chip_reset & 0x00000100)
43 if (watchdog_caused_reboot()) {
45#ifdef USE_RP2040_CRASH_HANDLER
52 if (watchdog_enable_caused_reboot()) {
61 if (
pos > 0 && buf[
pos - 1] ==
'|') {
63 }
else if (
pos == 0) {
75 constexpr size_t size = DEVICE_INFO_BUFFER_SIZE;
76 char *buf = buffer.data();
78 uint32_t cpu_freq = ::rp2040.f_cpu();
79 ESP_LOGD(TAG,
"CPU Frequency: %" PRIu32, cpu_freq);
80 pos = buf_append_printf(buf,
size,
pos,
"|CPU Frequency: %" PRIu32, cpu_freq);
const char * get_wakeup_cause_(std::span< char, WAKEUP_CAUSE_BUFFER_SIZE > buffer)
size_t get_device_info_(std::span< char, DEVICE_INFO_BUFFER_SIZE > buffer, size_t pos)
uint32_t get_free_heap_()
const char * get_reset_reason_(std::span< char, RESET_REASON_BUFFER_SIZE > buffer)
bool crash_handler_has_data()
Returns true if crash data was found this boot.
Providing packet encoding functions for exchanging data with a remote host.
size_t buf_append_str(char *buf, size_t size, size_t pos, const char *str)
Safely append a string to buffer without format parsing, returning new position (capped at size).