esp_ipc.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright 2015-2016 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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_IPC_H__
  14. #define __ESP_IPC_H__
  15. #include <esp_err.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #if !defined(CONFIG_FREERTOS_UNICORE) || defined(CONFIG_APPTRACE_GCOV_ENABLE)
  20. /** @cond */
  21. typedef void (*esp_ipc_func_t)(void* arg);
  22. /** @endcond */
  23. /*
  24. * Inter-processor call APIs
  25. *
  26. * FreeRTOS provides several APIs which can be used to communicate between
  27. * different tasks, including tasks running on different CPUs.
  28. * This module provides additional APIs to run some code on the other CPU.
  29. *
  30. * These APIs can only be used when FreeRTOS scheduler is running.
  31. */
  32. /**
  33. * @brief Execute a function on the given CPU
  34. *
  35. * Run a given function on a particular CPU. The given function must accept a
  36. * void* argument and return void. The given function is run in the context of
  37. * the IPC task of the CPU specified by the cpu_id parameter. The calling task
  38. * will be blocked until the IPC task begins executing the given function. If
  39. * another IPC call is ongoing, the calling task will block until the other IPC
  40. * call completes. The stack size allocated for the IPC task can be configured
  41. * in the "Inter-Processor Call (IPC) task stack size" setting in menuconfig.
  42. * Increase this setting if the given function requires more stack than default.
  43. *
  44. * @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
  45. *
  46. * @param[in] cpu_id CPU where the given function should be executed (0 or 1)
  47. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  48. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  49. *
  50. * @return
  51. * - ESP_ERR_INVALID_ARG if cpu_id is invalid
  52. * - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
  53. * - ESP_OK otherwise
  54. */
  55. esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
  56. /**
  57. * @brief Execute a function on the given CPU and blocks until it completes
  58. *
  59. * Run a given function on a particular CPU. The given function must accept a
  60. * void* argument and return void. The given function is run in the context of
  61. * the IPC task of the CPU specified by the cpu_id parameter. The calling task
  62. * will be blocked until the IPC task completes execution of the given function.
  63. * If another IPC call is ongoing, the calling task will block until the other
  64. * IPC call completes. The stack size allocated for the IPC task can be
  65. * configured in the "Inter-Processor Call (IPC) task stack size" setting in
  66. * menuconfig. Increase this setting if the given function requires more stack
  67. * than default.
  68. *
  69. * @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
  70. *
  71. * @param[in] cpu_id CPU where the given function should be executed (0 or 1)
  72. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  73. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  74. *
  75. * @return
  76. * - ESP_ERR_INVALID_ARG if cpu_id is invalid
  77. * - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
  78. * - ESP_OK otherwise
  79. */
  80. esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
  81. #endif // not CONFIG_FREERTOS_UNICORE or CONFIG_APPTRACE_GCOV_ENABLE
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif /* __ESP_IPC_H__ */