| 
									
										
										
										
											2017-11-22 15:16:29 +08:00
										 |  |  | Inter-Processor Call
 | 
					
						
							|  |  |  | ====================
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Overview
 | 
					
						
							|  |  |  | --------
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-12 15:20:41 +08:00
										 |  |  | Due to the dual core nature of the {IDF_TARGET_NAME}, there are instances where a certain
 | 
					
						
							| 
									
										
										
										
											2017-11-22 15:16:29 +08:00
										 |  |  | function must be run in the context of a particular core (e.g. allocating
 | 
					
						
							| 
									
										
										
										
											2021-03-12 15:20:41 +08:00
										 |  |  | ISR to an interrupt source of a particular core). The IPC (Inter-Processor
 | 
					
						
							| 
									
										
										
										
											2017-11-22 15:16:29 +08:00
										 |  |  | Call) feature allows for the execution of functions on a particular CPU.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-12 15:20:41 +08: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 15:16:29 +08:00
										 |  |  | implemented via two high priority FreeRTOS tasks pinned to each CPU known as
 | 
					
						
							| 
									
										
										
										
											2021-03-12 15:20:41 +08: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 15:16:29 +08: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 15:20:41 +08:00
										 |  |  | until the IPC Task begins execution of the given function.
 | 
					
						
							| 
									
										
										
										
											2017-11-22 15:16:29 +08: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 15:20:41 +08: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 12:51:55 +02:00
										 |  |  | :ref:`CONFIG_ESP_IPC_TASK_STACK_SIZE` in `menuconfig`. The IPC API is protected by a
 | 
					
						
							| 
									
										
										
										
											2017-11-22 15:16:29 +08: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-13 11:46:16 +08:00
										 |  |  | .. include-build-file:: inc/esp_ipc.inc
 | 
					
						
							| 
									
										
										
										
											2017-11-22 15:16:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 |