1 // Copyright 2010-2020 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 #include "sdkconfig.h"
17 #include <stdint.h>
18 #include "soc/reset_reasons.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /**
25  * @brief Print formated string to console device
26  * @note float and long long data are not supported!
27  *
28  * @param fmt Format string
29  * @param ... Additional arguments, depending on the format string
30  * @return int: Total number of characters written on success; A negative number on failure.
31  */
32 int esp_rom_printf(const char *fmt, ...);
33 
34 /**
35  * @brief Pauses execution for us microseconds
36  *
37  * @param us Number of microseconds to pause
38  */
39 void esp_rom_delay_us(uint32_t us);
40 
41 /**
42  * @brief esp_rom_printf can print message to different channels simultaneously.
43  *        This function can help install the low level putc function for esp_rom_printf.
44  *
45  * @param channel Channel number (startting from 1)
46  * @param putc Function pointer to the putc implementation. Set NULL can disconnect esp_rom_printf with putc.
47  */
48 void esp_rom_install_channel_putc(int channel, void (*putc)(char c));
49 
50 /**
51  * @brief Install UART1 as the default console channel, equivalent to `esp_rom_install_channel_putc(1, esp_rom_uart_putc)`
52  */
53 void esp_rom_install_uart_printf(void);
54 
55 /**
56  * @brief Get reset reason of CPU
57  *
58  * @param cpu_no CPU number
59  * @return Reset reason code (see in soc/reset_reasons.h)
60  */
61 soc_reset_reason_t esp_rom_get_reset_reason(int cpu_no);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66