rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
reset_cause.h
Go to the documentation of this file.
1
40
41#ifndef RCBENCH_RESET_CAUSE_H
42#define RCBENCH_RESET_CAUSE_H
43
44#include <stdbool.h>
45#include <stddef.h>
46#include <stdint.h>
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/* POWMAN CHIP_RESET: the source of the last chip-level reset. */
53#define RESET_CHIP_HAD_POR 0x00010000u
54#define RESET_CHIP_HAD_BOR 0x00020000u
55#define RESET_CHIP_HAD_RUN_LOW 0x00040000u
56#define RESET_CHIP_HAD_DP_RESET_REQ 0x00080000u
57#define RESET_CHIP_HAD_RESCUE 0x00200000u
58#define RESET_CHIP_HAD_WATCHDOG_RESET_POWMAN_ASYNC 0x00400000u
59#define RESET_CHIP_HAD_WATCHDOG_RESET_POWMAN 0x00800000u
60#define RESET_CHIP_HAD_WATCHDOG_RESET_SWCORE 0x01000000u
61#define RESET_CHIP_HAD_SWCORE_PD 0x02000000u
62#define RESET_CHIP_HAD_GLITCH_DETECT 0x04000000u
63#define RESET_CHIP_HAD_HZD_SYS_RESET_REQ 0x08000000u
64#define RESET_CHIP_HAD_WATCHDOG_RESET_PSM 0x10000000u
65
67#define RESET_CHIP_HAD_WATCHDOG_ANY \
68 (RESET_CHIP_HAD_WATCHDOG_RESET_POWMAN_ASYNC \
69 | RESET_CHIP_HAD_WATCHDOG_RESET_POWMAN \
70 | RESET_CHIP_HAD_WATCHDOG_RESET_SWCORE \
71 | RESET_CHIP_HAD_WATCHDOG_RESET_PSM)
72
73/* WATCHDOG REASON: both bits zero after a reset that was not the watchdog. */
74#define RESET_WD_REASON_TIMER 0x1u
75#define RESET_WD_REASON_FORCE 0x2u
76
77/* The boot type, byte 1 of the boot ROM's boot word (0xttppbbdd). */
78#define RESET_BOOT_TYPE_NORMAL 0x00u
79#define RESET_BOOT_TYPE_BOOTSEL 0x02u
80#define RESET_BOOT_TYPE_RAM_IMAGE 0x03u
81#define RESET_BOOT_TYPE_FLASH_UPDATE 0x04u
82#define RESET_BOOT_TYPE_PC_SP 0x0Du
83#define RESET_BOOT_TYPE_CHAINED_FLAG 0x80u
84
93#define RESET_PICOTOOL_P0 0xFFFFFFFFu
95#define RESET_PICOTOOL_P1 0x00000000u
96
100typedef struct {
101 uint32_t chip_reset;
102 uint32_t wd_reason;
103 uint32_t wd_scratch2;
104 uint32_t wd_scratch3;
105 bool boot_ok;
106 uint32_t boot_word;
107 uint32_t reboot_params[2];
109
128
163
172const char *reset_cause_word(reset_cause_t c);
173
181
195size_t reset_cause_full(const reset_regs_t *r, char *out, size_t n);
196
198#define RESET_CAUSE_FULL_MAX 144u
199
200#ifdef __cplusplus
201}
202#endif
203
204#endif /* RCBENCH_RESET_CAUSE_H */
size_t reset_cause_full(const reset_regs_t *r, char *out, size_t n)
The text of the start-up line and the 3s line, every raw value in hex: POR (chip_reset 0x00010000 rea...
Definition reset_cause.c:113
const char * reset_cause_word(reset_cause_t c)
The fixed word for a cause: POR, BOR, RUN_PIN, GLITCH, DEBUGGER, POWER_DOWN, FLASH_UPDATE,...
Definition reset_cause.c:94
int reset_cause_boot_type(const reset_regs_t *r)
The boot type in the boot word, without the chained flag.
Definition reset_cause.c:27
reset_cause_t
The causes reset_cause_decode() names.
Definition reset_cause.h:113
@ RESET_CAUSE_SW_RESET
Definition reset_cause.h:124
@ RESET_CAUSE_FLASH_UPDATE
Definition reset_cause.h:121
@ RESET_CAUSE_GLITCH
Definition reset_cause.h:118
@ RESET_CAUSE_WATCHDOG
Definition reset_cause.h:125
@ RESET_CAUSE_RUN_PIN
Definition reset_cause.h:117
@ RESET_CAUSE_UNKNOWN
Definition reset_cause.h:114
@ RESET_CAUSE_BOR
Definition reset_cause.h:116
@ RESET_CAUSE_DEBUGGER
Definition reset_cause.h:119
@ RESET_CAUSE_BOOTSEL_REBOOT
Definition reset_cause.h:123
@ RESET_CAUSE_POR
Definition reset_cause.h:115
@ RESET_CAUSE_RAM_IMAGE
Definition reset_cause.h:122
@ RESET_CAUSE_POWER_DOWN
Definition reset_cause.h:120
reset_cause_t reset_cause_decode(const reset_regs_t *r)
Names the cause of the last start.
Definition reset_cause.c:35
The raw values, as read at boot.
Definition reset_cause.h:100
uint32_t wd_scratch2
Definition reset_cause.h:103
uint32_t boot_word
Definition reset_cause.h:106
uint32_t chip_reset
Definition reset_cause.h:101
bool boot_ok
Definition reset_cause.h:105
uint32_t reboot_params[2]
Definition reset_cause.h:107
uint32_t wd_reason
Definition reset_cause.h:102
uint32_t wd_scratch3
Definition reset_cause.h:104