Example usage: /* A function called from an ISR. */ void vDemoFunction( void ) { UBaseType_t uxSavedInterruptStatus; /* Enter the critical section. In this example, this function is itself called from within a critical section, so entering this critical section will result in a nesting depth of 2. Save the value returned by taskENTER_CRITICAL_FROM_ISR() into a local stack variable so it can be passed into taskEXIT_CRITICAL_FROM_ISR(). */ uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR(); /* Perform the action that is being protected by the critical section here. */ /* Exit the critical section. In this example, this function is itself called from a critical section, so interrupts will have already been disabled before a value was stored in uxSavedInterruptStatus, and therefore passing uxSavedInterruptStatus into taskEXIT_CRITICAL_FROM_ISR() will not result in interrupts being re-enabled. */ taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus ); } /* A task that calls vDemoFunction() from within an interrupt service routine. */ void vDemoISR( void ) { UBaseType_t uxSavedInterruptStatus; /* Call taskENTER_CRITICAL_FROM_ISR() to create a critical section, saving the returned value into a local stack variable. */ uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR(); /* Execute the code that requires the critical section here. */ /* Calls to taskENTER_CRITICAL_FROM_ISR() can be nested so it is safe to call a function that includes its own calls to taskENTER_CRITICAL_FROM_ISR() and taskEXIT_CRITICAL_FROM_ISR(). */ vDemoFunction(); /* The operation that required the critical section is complete so exit the critical section. Assuming interrupts were enabled on entry to this ISR, the value saved in uxSavedInterruptStatus will result in interrupts being re-enabled.*/ taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus ); }
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|
Latest News
NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS. Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019 Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed. View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS. Careers
FreeRTOS and other embedded software careers at AWS. FreeRTOS Partners
|