1| Supported Targets | ESP32 | ESP32-S3 |
2| ----------------- | ----- | -------- |
3
4# IPC ISR Example
5
6This example demonstrates how to use the IPC ISR feature (which allows an IPC to run in the context of a High Priority Interrupt). The level of the IPC ISR interrupt depends on the `CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL` option. The IPC ISR feature can be useful in cases where users need to quickly get the state of the other CPU (consult the [IPC documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/ipc.html)). The `asm_funcs.S` file contains the callback that will be run on the other core. The callback should be fairly simple and must be entirely in assembly.
7
8The first assembly callback `get_ps_other_cpu()` demonstrates a callback that simply returns the `PS` register of other core.
9
10The second assembly callback `extended_ipc_isr_asm()` demonstrates a more complex callback that uses a buffer (provided as the callback's argument) to save some registers and return multiple values from the callback. The callback's `void *arg` points to a buffer containing the following:
11  - `uint32_t regs[];` that gives the callback an area to save some of the CPUs registers. Saving the registers gives the callback more scratch registers to use.
12  - `uint32_t in[];` that gives the callback multiple input arguments
13  - `uint32_t out[];` that gives the callback multiple output arguments
14
15The `extended_ipc_isr_asm()` callback will simply save/restore registers to/from `regs[]`, then use the arguments passed by `in[]` to do some work, then write the results to `out[]`.
16
17## How to use example
18
19### Hardware Required
20
21Example should be able to run on any commonly available ESP32 development board. The chip should have two cores.
22
23### Configure the project
24
25- `CONFIG_FREERTOS_UNICORE` - disabled,
26- `CONFIG_ESP_IPC_ISR_ENABLE` - enabled.
27
28```
29idf.py menuconfig
30```
31
32### Build and Flash
33
34```
35idf.py build flash monitor
36```
37
38(To exit the serial monitor, type ``Ctrl-]``.)
39
40See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
41
42
43## Example output
44
45```
46I (304) example: Start
47I (304) example: call get_ps_other_cpu
48I (314) example: PS_INTLEVEL = 0x5
49I (314) example: PS_EXCM = 0x0
50I (324) example: PS_UM = 0x1
51I (324) example: call extended_ipc_isr_asm
52I (324) example: in[0] = 0x1
53I (334) example: in[1] = 0x2
54I (334) example: in[2] = 0x3
55I (334) example: out[0] = (in[0] | in[1] | in[2]) = 0x3
56I (344) example: out[1] = (in[0] & in[1] & in[2]) = 0x6
57I (354) example: out[2] = in[2] = 0x3
58I (354) example: out[3] = PS of other cpu = 0x25
59I (364) example: End
60```
61