1 /*
2  * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #include "esp_err.h"
10 #include "../esp_task_wdt.h"
11 #include "esp_private/esp_task_wdt.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 
18 /**
19  * @brief   Allocate and initialize the Task Watchdog Timer (TWDT) with the given configuration.
20  *
21  * @param[in] config Pointer to the configuration structure
22  * @param[out] obj Abstract context for the current timer, this will be passed to all the other functions
23  *
24  * @return
25  *  - ESP_OK: Successfully initialized and configured the timer
26  *  - Other: Failed to initialize the timer
27  */
28 esp_err_t esp_task_wdt_impl_timer_allocate(const esp_task_wdt_config_t *config,
29                                            twdt_isr_callback callback,
30                                            twdt_ctx_t *obj);
31 
32 
33 /**
34  * @brief   Reconfigure a timer.
35  *
36  * The timer must be stopped when calling this function. The timer will not be restarted at the end of this
37  * function.
38  *
39  * @param[in] config Pointer to the configuration structure
40  *
41  * @return
42  *  - ESP_OK: Successfully reconfigured the timer
43  *  - Other: Failed to reconfigure the timer
44  */
45 esp_err_t esp_task_wdt_impl_timer_reconfigure(twdt_ctx_t obj, const esp_task_wdt_config_t *config);
46 
47 /**
48  * @brief   Free the Task Watchdog Timer (TWDT).
49  *
50  * @param[in] obj Abstract implementation context
51  *
52  */
53 void esp_task_wdt_impl_timer_free(twdt_ctx_t obj);
54 
55 
56 /**
57  * @brief   Feed the Task Watchdog Timer (TWDT)
58  *
59  * Feed the timer underneath to prevent it from triggering for the next period (configured at initialization).
60  *
61  * @param[in] obj Abstract implementation context
62  * @return
63  *  - ESP_OK: timer successfully feeded
64  *  - Other: failed to feed the timer
65  */
66 esp_err_t esp_task_wdt_impl_timer_feed(twdt_ctx_t obj);
67 
68 
69 /**
70  * @brief   Function invoked as soon as the Task Watchdog Timer (TWDT) ISR callback is called.
71  *
72  * @param[in] obj Abstract implementation context
73  */
74 void esp_task_wdt_impl_timeout_triggered(twdt_ctx_t obj);
75 
76 
77 /**
78  * @brief   Stop the Task Watchdog Timer (TWDT).
79  *
80  * @param[in] obj Abstract implementation context
81  *
82  */
83 esp_err_t esp_task_wdt_impl_timer_stop(twdt_ctx_t obj);
84 
85 
86 /**
87  * @brief   Restart the Task Watchdog Timer (TWDT)
88  *
89  * This function will restart/resume the timer after it has been stopped.
90  *
91  * @param[in] obj Abstract implementation context
92  * @return
93  *  - ESP_OK: timer successfully stopped
94  *  - Other: failed to stop the timer
95  */
96 esp_err_t esp_task_wdt_impl_timer_restart(twdt_ctx_t obj);
97 
98 
99 #ifdef __cplusplus
100 }
101 #endif
102