QueueHandle_t xQueue; void vFunction( void *pvParameters ) { /* Create a queue to hold one unsigned long value. It is strongly recommended not to use xQueueOverwriteFromISR() on queues that can contain more than one value, and doing so will trigger an assertion if configASSERT() is defined. */ xQueue = xQueueCreate( 1, sizeof( unsigned long ) ); } void vAnInterruptHandler( void ) { /* xHigherPriorityTaskWoken must be set to pdFALSE before it is used. */ BaseType_t xHigherPriorityTaskWoken = pdFALSE; unsigned long ulVarToSend, ulValReceived; /* Write the value 10 to the queue using xQueueOverwriteFromISR(). */ ulVarToSend = 10; xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken ); /* The queue is full, but calling xQueueOverwriteFromISR() again will still pass because the value held in the queue will be overwritten with the new value. */ ulVarToSend = 100; xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken ); /* Reading from the queue will now return 100. */ /* ... */ if( xHigherPrioritytaskWoken == pdTRUE ) { /* Writing to the queue caused a task to unblock and the unblocked task has a priority higher than or equal to the priority of the currently executing task (the task this interrupt interrupted). Perform a context switch so this interrupt returns directly to the unblocked task. */ portYIELD_FROM_ISR(); /* or portEND_SWITCHING_ISR() depending on the port.*/ } }
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
|