portBASE_TYPE vTaskResumeFromISR( xTaskHandle pxTaskToResume );INCLUDE_vTaskSuspend and INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be available. See the configuration section for more information.
A function to resume a suspended task that can be called from within an ISR.
A task that has been suspended by one of more calls to vTaskSuspend() will be made available for running again by a single call to xTaskResumeFromISR().
vTaskResumeFromISR() should not be used to synchronise a task with an interrupt if there is a chance that the interrupt could arrive prior to the task being suspended - as this can lead to interrupts being missed. Use of a semaphore as a synchronisation mechanism would avoid this eventuality.
| pxTaskToResume | Handle to the task being readied. |
| pdTRUE if resuming the task should result in a context switch, otherwise pdFALSE. This is used by the ISR to determine if a context switch may be required following the ISR. |
xTaskHandle xHandle;
void vAFunction( void )
{
// Create a task, storing the handle.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
// ... Rest of code.
}
void vTaskCode( void *pvParameters )
{
// The task being suspended and resumed.
for( ;; )
{
// ... Perform some function here.
// The task suspends itself.
vTaskSuspend( NULL );
// The task is now suspended, so will not reach here until the ISR resumes it.
}
}
void vAnExampleISR( void )
{
portBASE_TYPE xYieldRequired;
// Resume the suspended task.
xYieldRequired = xTaskResumeFromISR( xHandle );
if( xYieldRequired == pdTRUE )
{
// We should switch context so the ISR returns to a different task.
// NOTE: How this is done depends on the port you are using. Check
// the documentation and examples for your port.
portYIELD_FROM_ISR();
}
}