esp_vfs_dev.h 4.0 KB

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