1 // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include "esp_system.h"
22 
23 #define MWDT0_TICK_PRESCALER    40000
24 #define MWDT0_TICKS_PER_US      500
25 #define MWDT1_TICK_PRESCALER    40000
26 #define MWDT1_TICKS_PER_US      500
27 
28 /**
29  * @brief  Internal function to restart PRO and APP CPUs.
30  *
31  * @note This function should not be called from FreeRTOS applications.
32  *       Use esp_restart instead.
33  *
34  * This is an internal function called by esp_restart. It is called directly
35  * by the panic handler and brownout detector interrupt.
36  */
37 void esp_restart_noos(void) __attribute__ ((noreturn));
38 
39 /**
40  * @brief Similar to esp_restart_noos, but resets all the digital peripherals.
41  */
42 void esp_restart_noos_dig(void) __attribute__ ((noreturn));
43 
44 /**
45  * @brief  Internal function to set reset reason hint
46  *
47  * The hint is used do distinguish different reset reasons when software reset
48  * is performed.
49  *
50  * The hint is stored in RTC store register, RTC_RESET_CAUSE_REG.
51  *
52  * @param hint  Desired esp_reset_reason_t value for the real reset reason
53  */
54 void esp_reset_reason_set_hint(esp_reset_reason_t hint);
55 
56 /**
57  * @brief  Internal function to get the reset hint value
58  * @return  - Reset hint value previously stored into RTC_RESET_CAUSE_REG using
59  *          esp_reset_reason_set_hint function
60  *          - ESP_RST_UNKNOWN if the value in RTC_RESET_CAUSE_REG is invalid
61  */
62 esp_reset_reason_t esp_reset_reason_get_hint(void);
63 
64 /**
65  * @brief Get the time in microseconds since startup
66  *
67  * @returns time since g_startup_time; definition should be fixed by system time provider
68  * no matter the underlying timer used.
69  */
70 int64_t esp_system_get_time(void);
71 
72 /**
73  * @brief Get the resolution of the time returned by `esp_system_get_time`.
74  *
75  * @returns the resolution in nanoseconds
76  */
77 uint32_t esp_system_get_time_resolution(void);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82