esp_vfs_dev.h 3.9 KB

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