#include "freertos/semphr.h"
-static TaskHandle_t s_ipc_tasks[portNUM_PROCESSORS]; // Two high priority tasks, one for each CPU
static SemaphoreHandle_t s_ipc_mutex; // This mutex is used as a global lock for esp_ipc_* APIs
-static SemaphoreHandle_t s_ipc_sem[portNUM_PROCESSORS]; // Two semaphores used to wake each of s_ipc_tasks
+static SemaphoreHandle_t s_ipc_sem[portNUM_PROCESSORS]; // Two semaphores used to wake each of ipc tasks
static SemaphoreHandle_t s_ipc_ack; // Semaphore used to acknowledge that task was woken up,
// or function has finished running
static volatile esp_ipc_func_t s_func; // Function which should be called by high priority task
s_ipc_ack = xSemaphoreCreateBinary();
char task_name[15];
for (int i = 0; i < portNUM_PROCESSORS; ++i) {
- sprintf(task_name,"ipc%d",i);
+ snprintf(task_name, sizeof(task_name), "ipc%d", i);
s_ipc_sem[i] = xSemaphoreCreateBinary();
portBASE_TYPE res = xTaskCreatePinnedToCore(ipc_task, task_name, CONFIG_IPC_TASK_STACK_SIZE, (void*) i,
- configMAX_PRIORITIES - 1, &s_ipc_tasks[i], i);
+ configMAX_PRIORITIES - 1, NULL, i);
assert(res == pdTRUE);
}
}
s_func = func;
s_func_arg = arg;
- s_ipc_wait = IPC_WAIT_FOR_START;
+ s_ipc_wait = wait_for;
xSemaphoreGive(s_ipc_sem[cpu_id]);
xSemaphoreTake(s_ipc_ack, portMAX_DELAY);
xSemaphoreGive(s_ipc_mutex);
--- /dev/null
+#include <stdio.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "unity.h"
+#include "esp_ipc.h"
+
+static void test_func_ipc_cb(void *arg)
+{
+ vTaskDelay(50);
+ int *val = (int *)arg;
+ *val = 0xa5a5;
+}
+
+TEST_CASE("Test blocking IPC function call", "[ipc]")
+{
+ int val = 0x5a5a;
+#ifdef CONFIG_FREERTOS_UNICORE
+ esp_ipc_call_blocking(xPortGetCoreID(), test_func_ipc_cb, &val);
+#else
+ esp_ipc_call_blocking(!xPortGetCoreID(), test_func_ipc_cb, &val);
+#endif
+ TEST_ASSERT_EQUAL_HEX(val, 0xa5a5);
+}