1
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* ... */
/* ... */
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "soc/rtc_periph.h"
#include "esp_err.h"
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
#ifdef __cplusplus
extern "C"
{
#endif
typedef enum {
RTC_WDT_STAGE0 = 0,
RTC_WDT_STAGE1 = 1,
RTC_WDT_STAGE2 = 2,
RTC_WDT_STAGE3 = 3
} rtc_wdt_stage_t;
typedef enum {
RTC_WDT_STAGE_ACTION_OFF = RTC_WDT_STG_SEL_OFF,
RTC_WDT_STAGE_ACTION_INTERRUPT = RTC_WDT_STG_SEL_INT,
RTC_WDT_STAGE_ACTION_RESET_CPU = RTC_WDT_STG_SEL_RESET_CPU,
RTC_WDT_STAGE_ACTION_RESET_SYSTEM = RTC_WDT_STG_SEL_RESET_SYSTEM,
RTC_WDT_STAGE_ACTION_RESET_RTC = RTC_WDT_STG_SEL_RESET_RTC
} rtc_wdt_stage_action_t;
typedef enum {
RTC_WDT_SYS_RESET_SIG = 0,
RTC_WDT_CPU_RESET_SIG = 1
} rtc_wdt_reset_sig_t;
typedef enum {
RTC_WDT_LENGTH_100ns = 0,
RTC_WDT_LENGTH_200ns = 1,
RTC_WDT_LENGTH_300ns = 2,
RTC_WDT_LENGTH_400ns = 3,
RTC_WDT_LENGTH_500ns = 4,
RTC_WDT_LENGTH_800ns = 5,
RTC_WDT_LENGTH_1_6us = 6,
RTC_WDT_LENGTH_3_2us = 7
} rtc_wdt_length_sig_t;
bool rtc_wdt_get_protect_status(void);
void rtc_wdt_protect_on(void);
void rtc_wdt_protect_off(void);
void rtc_wdt_enable(void);
void rtc_wdt_flashboot_mode_enable(void);
void rtc_wdt_disable(void);
void rtc_wdt_feed(void);
esp_err_t rtc_wdt_set_time(rtc_wdt_stage_t stage, unsigned int timeout_ms);
esp_err_t rtc_wdt_get_timeout(rtc_wdt_stage_t stage, unsigned int* timeout_ms);
esp_err_t rtc_wdt_set_stage(rtc_wdt_stage_t stage, rtc_wdt_stage_action_t stage_sel);
esp_err_t rtc_wdt_set_length_of_reset_signal(rtc_wdt_reset_sig_t reset_src, rtc_wdt_length_sig_t reset_signal_length);
bool rtc_wdt_is_on(void);
#ifdef __cplusplus
}
#endif
#endif