1 /*
2  * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #include "esp_vfs.h"
10 #include "esp_vfs_common.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * @brief add /dev/uart virtual filesystem driver
18  *
19  * This function is called from startup code to enable serial output
20  */
21 void esp_vfs_dev_uart_register(void);
22 
23 /**
24  * @brief Set the line endings expected to be received on UART
25  *
26  * This specifies the conversion between line endings received on UART and
27  * newlines ('\n', LF) passed into stdin:
28  *
29  * - ESP_LINE_ENDINGS_CRLF: convert CRLF to LF
30  * - ESP_LINE_ENDINGS_CR: convert CR to LF
31  * - ESP_LINE_ENDINGS_LF: no modification
32  *
33  * @note this function is not thread safe w.r.t. reading from UART
34  *
35  * @param mode line endings expected on UART
36  */
37 void esp_vfs_dev_uart_set_rx_line_endings(esp_line_endings_t mode) __attribute__((deprecated));
38 
39 /**
40  * @brief Set the line endings to sent to UART
41  *
42  * This specifies the conversion between newlines ('\n', LF) on stdout and line
43  * endings sent over UART:
44  *
45  * - ESP_LINE_ENDINGS_CRLF: convert LF to CRLF
46  * - ESP_LINE_ENDINGS_CR: convert LF to CR
47  * - ESP_LINE_ENDINGS_LF: no modification
48  *
49  * @note this function is not thread safe w.r.t. writing to UART
50  *
51  * @param mode line endings to send to UART
52  */
53 void esp_vfs_dev_uart_set_tx_line_endings(esp_line_endings_t mode) __attribute__((deprecated));
54 
55 /**
56  * @brief Set the line endings expected to be received on specified UART
57  *
58  * This specifies the conversion between line endings received on UART and
59  * newlines ('\n', LF) passed into stdin:
60  *
61  * - ESP_LINE_ENDINGS_CRLF: convert CRLF to LF
62  * - ESP_LINE_ENDINGS_CR: convert CR to LF
63  * - ESP_LINE_ENDINGS_LF: no modification
64  *
65  * @note this function is not thread safe w.r.t. reading from UART
66  *
67  * @param uart_num the UART number
68  * @param mode line endings to send to UART
69  * @return  0 if successed, or -1
70  *              when an error (specified by errno) have occurred.
71  */
72 int esp_vfs_dev_uart_port_set_rx_line_endings(int uart_num, esp_line_endings_t mode);
73 
74 /**
75  * @brief Set the line endings to sent to specified UART
76  *
77  * This specifies the conversion between newlines ('\n', LF) on stdout and line
78  * endings sent over UART:
79  *
80  * - ESP_LINE_ENDINGS_CRLF: convert LF to CRLF
81  * - ESP_LINE_ENDINGS_CR: convert LF to CR
82  * - ESP_LINE_ENDINGS_LF: no modification
83  *
84  * @note this function is not thread safe w.r.t. writing to UART
85  *
86  * @param uart_num the UART number
87  * @param mode line endings to send to UART
88   * @return  0 if successed, or -1
89  *              when an error (specified by errno) have occurred.
90  */
91 int esp_vfs_dev_uart_port_set_tx_line_endings(int uart_num, esp_line_endings_t mode);
92 
93 /**
94  * @brief set VFS to use simple functions for reading and writing UART
95  * Read is non-blocking, write is busy waiting until TX FIFO has enough space.
96  * These functions are used by default.
97  * @param uart_num UART peripheral number
98  */
99 void esp_vfs_dev_uart_use_nonblocking(int uart_num);
100 
101 /**
102  * @brief set VFS to use UART driver for reading and writing
103  * @note application must configure UART driver before calling these functions
104  * With these functions, read and write are blocking and interrupt-driven.
105  * @param uart_num UART peripheral number
106  */
107 void esp_vfs_dev_uart_use_driver(int uart_num);
108 
109 /**
110  * @brief set VFS to use USB-SERIAL-JTAG driver for reading and writing
111  * @note application must configure USB-SERIAL-JTAG driver before calling these functions
112  * With these functions, read and write are blocking and interrupt-driven.
113  */
114 void esp_vfs_usb_serial_jtag_use_driver(void);
115 
116 /**
117  * @brief set VFS to use simple functions for reading and writing UART
118  * Read is non-blocking, write is busy waiting until TX FIFO has enough space.
119  * These functions are used by default.
120  */
121 void esp_vfs_usb_serial_jtag_use_nonblocking(void);
122 
123 #ifdef __cplusplus
124 }
125 #endif
126