esp_vfs_dev.h 4.3 KB

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