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