| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- /*
- * FreeRTOS Kernel V10.4.6
- * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * https://www.FreeRTOS.org
- * https://github.com/FreeRTOS
- *
- */
- #ifndef QUEUE_H
- #define QUEUE_H
- /* *INDENT-OFF* */
- #ifdef __cplusplus
- extern "C" {
- #endif
- /* *INDENT-ON* */
- /**
- * Type by which queues are referenced. For example, a call to xQueueCreate()
- * returns an QueueHandle_t variable that can then be used as a parameter to
- * xQueueSend(), xQueueReceive(), etc.
- */
- struct QueueDefinition; /* Using old naming convention so as not to break kernel aware debuggers. */
- typedef struct QueueDefinition * QueueHandle_t;
- /* For internal use only. */
- #define queueSEND_TO_BACK ( ( BaseType_t ) 0 )
- #define queueSEND_TO_FRONT ( ( BaseType_t ) 1 )
- #define queueOVERWRITE ( ( BaseType_t ) 2 )
- /* For internal use only. These definitions *must* match those in queue.c. */
- #define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U )
- #define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U )
- #define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U )
- #define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U )
- #define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U )
- #define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U )
- /**
- * queue. h
- * @code{c}
- * BaseType_t xQueueGenericSend(
- * QueueHandle_t xQueue,
- * const void * pvItemToQueue,
- * TickType_t xTicksToWait
- * BaseType_t xCopyPosition
- * );
- * @endcode
- *
- * It is preferred that the macros xQueueSend(), xQueueSendToFront() and
- * xQueueSendToBack() are used in place of calling this function directly.
- *
- * Post an item on a queue. The item is queued by copy, not by reference.
- * This function must not be called from an interrupt service routine.
- * See xQueueSendFromISR () for an alternative which may be used in an ISR.
- *
- * @param xQueue The handle to the queue on which the item is to be posted.
- *
- * @param pvItemToQueue A pointer to the item that is to be placed on the
- * queue. The size of the items the queue will hold was defined when the
- * queue was created, so this many bytes will be copied from pvItemToQueue
- * into the queue storage area.
- *
- * @param xTicksToWait The maximum amount of time the task should block
- * waiting for space to become available on the queue, should it already
- * be full. The call will return immediately if this is set to 0 and the
- * queue is full. The time is defined in tick periods so the constant
- * portTICK_PERIOD_MS should be used to convert to real time if this is required.
- *
- * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
- * item at the back of the queue, or queueSEND_TO_FRONT to place the item
- * at the front of the queue (for high priority messages).
- *
- * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
- *
- * Example usage:
- * @code{c}
- * struct AMessage
- * {
- * char ucMessageID;
- * char ucData[ 20 ];
- * } xMessage;
- *
- * uint32_t ulVar = 10UL;
- *
- * void vATask( void *pvParameters )
- * {
- * QueueHandle_t xQueue1, xQueue2;
- * struct AMessage *pxMessage;
- *
- * // Create a queue capable of containing 10 uint32_t values.
- * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
- *
- * // Create a queue capable of containing 10 pointers to AMessage structures.
- * // These should be passed by pointer as they contain a lot of data.
- * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
- *
- * // ...
- *
- * if( xQueue1 != 0 )
- * {
- * // Send an uint32_t. Wait for 10 ticks for space to become
- * // available if necessary.
- * if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )
- * {
- * // Failed to post the message, even after 10 ticks.
- * }
- * }
- *
- * if( xQueue2 != 0 )
- * {
- * // Send a pointer to a struct AMessage object. Don't block if the
- * // queue is already full.
- * pxMessage = & xMessage;
- * xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );
- * }
- *
- * // ... Rest of task code.
- * }
- * @endcode
- * \defgroup xQueueSend xQueueSend
- * \ingroup QueueManagement
- */
- BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
- const void * const pvItemToQueue,
- TickType_t xTicksToWait,
- const BaseType_t xCopyPosition );
- /**
- * queue. h
- * @code{c}
- * void vQueueDelete( QueueHandle_t xQueue );
- * @endcode
- *
- * Delete a queue - freeing all the memory allocated for storing of items
- * placed on the queue.
- *
- * @param xQueue A handle to the queue to be deleted.
- *
- * \defgroup vQueueDelete vQueueDelete
- * \ingroup QueueManagement
- */
- void vQueueDelete( QueueHandle_t xQueue );
- BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
- BaseType_t * const pxHigherPriorityTaskWoken );
- /**
- * queue. h
- * @code{c}
- * BaseType_t xQueueReceiveFromISR(
- * QueueHandle_t xQueue,
- * void *pvBuffer,
- * BaseType_t *pxTaskWoken
- * );
- * @endcode
- *
- * Receive an item from a queue. It is safe to use this function from within an
- * interrupt service routine.
- *
- * @param xQueue The handle to the queue from which the item is to be
- * received.
- *
- * @param pvBuffer Pointer to the buffer into which the received item will
- * be copied.
- *
- * @param pxTaskWoken A task may be blocked waiting for space to become
- * available on the queue. If xQueueReceiveFromISR causes such a task to
- * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
- * remain unchanged.
- *
- * @return pdTRUE if an item was successfully received from the queue,
- * otherwise pdFALSE.
- *
- * Example usage:
- * @code{c}
- *
- * QueueHandle_t xQueue;
- *
- * // Function to create a queue and post some values.
- * void vAFunction( void *pvParameters )
- * {
- * char cValueToPost;
- * const TickType_t xTicksToWait = ( TickType_t )0xff;
- *
- * // Create a queue capable of containing 10 characters.
- * xQueue = xQueueCreate( 10, sizeof( char ) );
- * if( xQueue == 0 )
- * {
- * // Failed to create the queue.
- * }
- *
- * // ...
- *
- * // Post some characters that will be used within an ISR. If the queue
- * // is full then this task will block for xTicksToWait ticks.
- * cValueToPost = 'a';
- * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
- * cValueToPost = 'b';
- * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
- *
- * // ... keep posting characters ... this task may block when the queue
- * // becomes full.
- *
- * cValueToPost = 'c';
- * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
- * }
- *
- * // ISR that outputs all the characters received on the queue.
- * void vISR_Routine( void )
- * {
- * BaseType_t xTaskWokenByReceive = pdFALSE;
- * char cRxedChar;
- *
- * while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
- * {
- * // A character was received. Output the character now.
- * vOutputCharacter( cRxedChar );
- *
- * // If removing the character from the queue woke the task that was
- * // posting onto the queue cTaskWokenByReceive will have been set to
- * // pdTRUE. No matter how many times this loop iterates only one
- * // task will be woken.
- * }
- *
- * if( cTaskWokenByPost != ( char ) pdFALSE;
- * {
- * taskYIELD ();
- * }
- * }
- * @endcode
- * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
- * \ingroup QueueManagement
- */
- BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue,
- void * const pvBuffer,
- BaseType_t * const pxHigherPriorityTaskWoken );
- /*
- * For internal use only. Use xSemaphoreCreateMutex(),
- * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling
- * these functions directly.
- */
- QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType );
- QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType,
- StaticQueue_t * pxStaticQueue );
- QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
- const UBaseType_t uxInitialCount );
- QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
- const UBaseType_t uxInitialCount,
- StaticQueue_t * pxStaticQueue );
- BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
- TickType_t xTicksToWait );
- /*
- * For internal use only. Use xSemaphoreTakeMutexRecursive() or
- * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.
- */
- BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex,
- TickType_t xTicksToWait );
- BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex );
- /*
- * Generic version of the function used to create a queue using dynamic memory
- * allocation. This is called by other functions and macros that create other
- * RTOS objects that use the queue structure as their base.
- */
- #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
- QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength,
- const UBaseType_t uxItemSize,
- const uint8_t ucQueueType );
- #endif
- /*
- * Generic version of the function used to create a queue using dynamic memory
- * allocation. This is called by other functions and macros that create other
- * RTOS objects that use the queue structure as their base.
- */
- #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
- QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
- const UBaseType_t uxItemSize,
- uint8_t * pucQueueStorage,
- StaticQueue_t * pxStaticQueue,
- const uint8_t ucQueueType );
- #endif
- /* *INDENT-OFF* */
- #ifdef __cplusplus
- }
- #endif
- /* *INDENT-ON* */
- #endif /* QUEUE_H */
|