esp_ipc.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_err.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #if !defined(CONFIG_FREERTOS_UNICORE) || defined(CONFIG_APPTRACE_GCOV_ENABLE)
  12. /*
  13. * Inter-processor call APIs
  14. *
  15. * FreeRTOS provides several APIs which can be used to communicate between different tasks, including tasks running on
  16. * different CPUs. This module provides additional APIs to run some code on the other CPU. These APIs can only be used
  17. * when FreeRTOS scheduler is running.
  18. */
  19. /**
  20. * @brief IPC Callback
  21. *
  22. * A callback of this type should be provided as an argument when calling esp_ipc_call() or esp_ipc_call_blocking().
  23. */
  24. typedef void (*esp_ipc_func_t)(void* arg);
  25. /**
  26. * @brief Execute a callback on a given CPU
  27. *
  28. * Execute a given callback on a particular CPU. The callback must be of type "esp_ipc_func_t" and will be invoked in
  29. * the context of the target CPU's IPC task.
  30. *
  31. * - This function will block the target CPU's IPC task has begun execution of the callback
  32. * - If another IPC call is ongoing, this function will block until the ongoing IPC call completes
  33. * - The stack size of the IPC task can be configured via the CONFIG_ESP_IPC_TASK_STACK_SIZE option
  34. *
  35. * @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
  36. *
  37. * @param[in] cpu_id CPU where the given function should be executed (0 or 1)
  38. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  39. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  40. *
  41. * @return
  42. * - ESP_ERR_INVALID_ARG if cpu_id is invalid
  43. * - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
  44. * - ESP_OK otherwise
  45. */
  46. esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
  47. /**
  48. * @brief Execute a callback on a given CPU until and block until it completes
  49. *
  50. * This function is identical to esp_ipc_call() except that this function will block until the execution of the callback
  51. * completes.
  52. *
  53. * @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
  54. *
  55. * @param[in] cpu_id CPU where the given function should be executed (0 or 1)
  56. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  57. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  58. *
  59. * @return
  60. * - ESP_ERR_INVALID_ARG if cpu_id is invalid
  61. * - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
  62. * - ESP_OK otherwise
  63. */
  64. esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
  65. #endif // !defined(CONFIG_FREERTOS_UNICORE) || defined(CONFIG_APPTRACE_GCOV_ENABLE)
  66. #ifdef __cplusplus
  67. }
  68. #endif