1 /*
2  * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #include "../esp_ipc.h"
10 #include "sdkconfig.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #if !defined(CONFIG_FREERTOS_UNICORE) || defined(CONFIG_APPTRACE_GCOV_ENABLE)
17 
18 /**
19  * @brief Execute a callback on a given CPU without any blocking operations for the caller
20  *
21  * Since it does not have any blocking operations it is suitable to be run from interrupts
22  * or even when the Scheduler on the current core is suspended.
23  *
24  * The function:
25  * - does not wait for the callback to begin or complete execution,
26  * - does not change the IPC priority.
27  * The function returns after sending a notification to the IPC task to execute the callback.
28  *
29  * @param[in]   cpu_id  CPU where the given function should be executed (0 or 1)
30  * @param[in]   func    Pointer to a function of type void func(void* arg) to be executed
31  * @param[in]   arg     Arbitrary argument of type void* to be passed into the function
32  *
33  * @return
34  *      - ESP_ERR_INVALID_ARG if cpu_id is invalid
35  *      - ESP_ERR_INVALID_STATE 1. IPC tasks have not been initialized yet,
36  *                              2. cpu_id requests IPC on the current core, but the FreeRTOS scheduler is not running on it
37  *                              (the IPC task cannot be executed).
38  *      - ESP_FAIL IPC is busy due to a previous call was not completed.
39  *      - ESP_OK otherwise
40  */
41 esp_err_t esp_ipc_call_nonblocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
42 
43 #endif // !defined(CONFIG_FREERTOS_UNICORE) || defined(CONFIG_APPTRACE_GCOV_ENABLE)
44 
45 #ifdef __cplusplus
46 }
47 #endif
48