MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / xQueueGenericSendFromISR

Function xQueueGenericSendFromISR

queue.c:987–1151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985/*-----------------------------------------------------------*/
986
987BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
988 const void * const pvItemToQueue,
989 BaseType_t * const pxHigherPriorityTaskWoken,
990 const BaseType_t xCopyPosition )
991{
992 BaseType_t xReturn;
993 UBaseType_t uxSavedInterruptStatus;
994 Queue_t * const pxQueue = xQueue;
995
996 configASSERT( pxQueue );
997 configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
998 configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );
999
1000 /* RTOS ports that support interrupt nesting have the concept of a maximum
1001 * system call (or maximum API call) interrupt priority. Interrupts that are
1002 * above the maximum system call priority are kept permanently enabled, even
1003 * when the RTOS kernel is in a critical section, but cannot make any calls to
1004 * FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h
1005 * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion
1006 * failure if a FreeRTOS API function is called from an interrupt that has been
1007 * assigned a priority above the configured maximum system call priority.
1008 * Only FreeRTOS functions that end in FromISR can be called from interrupts
1009 * that have been assigned a priority at or (logically) below the maximum
1010 * system call interrupt priority. FreeRTOS maintains a separate interrupt
1011 * safe API to ensure interrupt entry is as fast and as simple as possible.
1012 * More information (albeit Cortex-M specific) is provided on the following
1013 * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
1014 portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
1015
1016 /* Similar to xQueueGenericSend, except without blocking if there is no room
1017 * in the queue. Also don't directly wake a task that was blocked on a queue
1018 * read, instead return a flag to say whether a context switch is required or
1019 * not (i.e. has a task with a higher priority than us been woken by this
1020 * post). */
1021 uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
1022 {
1023 if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
1024 {
1025 const int8_t cTxLock = pxQueue->cTxLock;
1026 const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;
1027
1028 traceQUEUE_SEND_FROM_ISR( pxQueue );
1029
1030 /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a
1031 * semaphore or mutex. That means prvCopyDataToQueue() cannot result
1032 * in a task disinheriting a priority and prvCopyDataToQueue() can be
1033 * called here even though the disinherit function does not check if
1034 * the scheduler is suspended before accessing the ready lists. */
1035 ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
1036
1037 /* The event list is not altered if the queue is locked. This will
1038 * be done when the queue is unlocked later. */
1039 if( cTxLock == queueUNLOCKED )
1040 {
1041 #if ( configUSE_QUEUE_SETS == 1 )
1042 {
1043 if( pxQueue->pxQueueSetContainer != NULL )
1044 {

Callers

nothing calls this directly

Calls 3

prvCopyDataToQueueFunction · 0.85
xTaskRemoveFromEventListFunction · 0.85

Tested by

no test coverage detected