esp_openthread_task_queue.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.h"
  9. #include "esp_openthread_types.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief OpenThread task declaration
  15. *
  16. */
  17. typedef void (*esp_openthread_task_t)(void *);
  18. /**
  19. * @brief This function allocs and initializes the OpenThread task queue.
  20. *
  21. * @param[in] config The platform configuration
  22. *
  23. * @return
  24. * - ESP_OK on success
  25. * - ESP_ERR_NO_MEM on queue allocation failure
  26. * - ESP_FAIL on other failures
  27. *
  28. */
  29. esp_err_t esp_openthread_task_queue_init(const esp_openthread_platform_config_t *config);
  30. /**
  31. * @brief This function posts a task to the OpenThread task queue.
  32. *
  33. * @param[in] task The task to execute.
  34. * @param[in] arg The context argument to be passed to the task.
  35. *
  36. * @return
  37. * - ESP_OK
  38. * - ESP_FAIL
  39. *
  40. */
  41. esp_err_t esp_openthread_task_queue_post(esp_openthread_task_t task, void *arg);
  42. /**
  43. * @brief This function updates the task queue inner fd to the main loop.
  44. *
  45. * @param[inout] mainloop The main loop context.
  46. *
  47. */
  48. void esp_openthread_task_queue_update(esp_openthread_mainloop_context_t *mainloop);
  49. /**
  50. * @brief This function drives the execution of the task queue.
  51. *
  52. * @param[in] instance The OpenThread instance.
  53. * @param[in] mainloop The main loop context.
  54. *
  55. * @return
  56. * - ESP_OK
  57. * - ESP_FAIL
  58. *
  59. */
  60. esp_err_t esp_openthread_task_queue_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop);
  61. /**
  62. * @brief This function deinitializes the task queue.
  63. *
  64. * @return
  65. * - ESP_OK
  66. * - ESP_FAIL
  67. *
  68. */
  69. esp_err_t esp_openthread_task_queue_deinit(void);
  70. #ifdef __cplusplus
  71. }
  72. #endif