esp_openthread_uart.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 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 uart for OpenThread host connection.
  28. *
  29. * @param[in] config The uart configuration.
  30. *
  31. * @return
  32. * - ESP_OK on success
  33. * - ESP_ERROR on failure
  34. *
  35. */
  36. esp_err_t esp_openthread_uart_init(const esp_openthread_platform_config_t *config);
  37. /**
  38. * @brief Deintializes the uart for OpenThread host connection.
  39. *
  40. */
  41. void esp_openthread_uart_deinit(void);
  42. /**
  43. * @brief Deintializes the uart for OpenThread host connection.
  44. *
  45. * @param[inout] mainloop The main loop context.
  46. *
  47. */
  48. void esp_openthread_uart_update(esp_openthread_mainloop_context_t *context);
  49. /**
  50. * @brief Performs the uart I/O for OpenThread.
  51. *
  52. * @param[in] instance The Openthread instance.
  53. * @param[in] mainloop The main loop context.
  54. *
  55. * @return
  56. * - ESP_OK on success
  57. * - ESP_ERROR on failure
  58. *
  59. */
  60. esp_err_t esp_openthread_uart_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop);
  61. #ifdef __cplusplus
  62. }
  63. #endif