esp_openthread_uart.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "esp_err.h"
  8. #include "esp_openthread_types.h"
  9. #include "openthread/instance.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief Initializes an uart port with the given config.
  15. *
  16. * @note The user still needs to open the file descriptor by self.
  17. *
  18. * @param[in] config The uart configuration.
  19. *
  20. * @return
  21. * - ESP_OK on success
  22. * - ESP_ERROR on failure
  23. *
  24. */
  25. esp_err_t esp_openthread_uart_init_port(const esp_openthread_uart_config_t *config);
  26. /**
  27. * @brief Initializes the console UART for OpenThread host connection.
  28. *
  29. * @param[in] config The platform configuration.
  30. *
  31. * @return
  32. * - ESP_OK on success
  33. * - ESP_ERROR on failure
  34. *
  35. */
  36. esp_err_t esp_openthread_host_cli_uart_init(const esp_openthread_platform_config_t *config);
  37. /**
  38. * @brief Initializes the console USB JTAG for OpenThread host connection.
  39. *
  40. * @param[in] config The platform configuration.
  41. *
  42. * @return
  43. * - ESP_OK on success
  44. * - ESP_ERROR on failure
  45. *
  46. */
  47. esp_err_t esp_openthread_host_cli_usb_init(const esp_openthread_platform_config_t *config);
  48. /**
  49. * @brief Initializes the RCP UART for OpenThread host connection.
  50. *
  51. * @param[in] config The platform configuration.
  52. *
  53. * @return
  54. * - ESP_OK on success
  55. * - ESP_ERROR on failure
  56. *
  57. */
  58. esp_err_t esp_openthread_host_rcp_uart_init(const esp_openthread_platform_config_t *config);
  59. /**
  60. * @brief Deintializes the uart for OpenThread host connection.
  61. *
  62. */
  63. void esp_openthread_uart_deinit(void);
  64. /**
  65. * @brief Deintializes the uart for OpenThread host connection.
  66. *
  67. * @param[inout] mainloop The main loop context.
  68. *
  69. */
  70. void esp_openthread_uart_update(esp_openthread_mainloop_context_t *context);
  71. /**
  72. * @brief Performs the uart I/O for OpenThread.
  73. *
  74. * @param[in] instance The Openthread instance.
  75. * @param[in] mainloop The main loop context.
  76. *
  77. * @return
  78. * - ESP_OK on success
  79. * - ESP_ERROR on failure
  80. *
  81. */
  82. esp_err_t esp_openthread_uart_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop);
  83. #ifdef __cplusplus
  84. }
  85. #endif