2017-11-22 02:16:29 -05:00
|
|
|
Inter-Processor Call
|
|
|
|
====================
|
|
|
|
|
|
|
|
Overview
|
|
|
|
--------
|
|
|
|
|
2021-03-12 02:20:41 -05:00
|
|
|
Due to the dual core nature of the {IDF_TARGET_NAME}, there are instances where a certain
|
2017-11-22 02:16:29 -05:00
|
|
|
function must be run in the context of a particular core (e.g. allocating
|
2021-03-12 02:20:41 -05:00
|
|
|
ISR to an interrupt source of a particular core). The IPC (Inter-Processor
|
2017-11-22 02:16:29 -05:00
|
|
|
Call) feature allows for the execution of functions on a particular CPU.
|
|
|
|
|
2021-03-12 02:20:41 -05:00
|
|
|
A given function can be executed on a particular core by calling
|
|
|
|
:cpp:func:`esp_ipc_call` or :cpp:func:`esp_ipc_call_blocking`. IPC is
|
2017-11-22 02:16:29 -05:00
|
|
|
implemented via two high priority FreeRTOS tasks pinned to each CPU known as
|
2021-03-12 02:20:41 -05:00
|
|
|
the IPC Tasks. The two IPC Tasks remain inactive (blocked) until
|
|
|
|
:cpp:func:`esp_ipc_call` or :cpp:func:`esp_ipc_call_blocking` is called. When
|
|
|
|
an IPC Task of a particular core is unblocked, it will preempt the current
|
|
|
|
running task on that core and execute a given function.
|
2017-11-22 02:16:29 -05:00
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
|
|
|
:cpp:func:`esp_ipc_call` unblocks the IPC task on a particular core to execute
|
|
|
|
a given function. The task that calls :cpp:func:`esp_ipc_call` will be blocked
|
2021-03-12 02:20:41 -05:00
|
|
|
until the IPC Task begins execution of the given function.
|
2017-11-22 02:16:29 -05:00
|
|
|
:cpp:func:`esp_ipc_call_blocking` is similar but will block the calling task
|
|
|
|
until the IPC Task has completed execution of the given function.
|
2021-03-12 02:20:41 -05:00
|
|
|
|
|
|
|
Functions executed by IPCs must be functions of type
|
|
|
|
`void func(void *arg)`. To run more complex functions which require a larger
|
|
|
|
stack, the IPC tasks' stack size can be configured by modifying
|
2019-04-30 06:51:55 -04:00
|
|
|
:ref:`CONFIG_ESP_IPC_TASK_STACK_SIZE` in `menuconfig`. The IPC API is protected by a
|
2017-11-22 02:16:29 -05:00
|
|
|
mutex hence simultaneous IPC calls are not possible.
|
|
|
|
|
|
|
|
Care should taken to avoid deadlock when writing functions to be executed by
|
|
|
|
IPC, especially when attempting to take a mutex within the function.
|
|
|
|
|
|
|
|
API Reference
|
|
|
|
-------------
|
|
|
|
|
2019-11-12 22:46:16 -05:00
|
|
|
.. include-build-file:: inc/esp_ipc.inc
|
2017-11-22 02:16:29 -05:00
|
|
|
|
|
|
|
|