#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U )
#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U )
-
+/** @cond */
/**
- * semphr. h
- * <pre>vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )</pre>
- *
* This old vSemaphoreCreateBinary() macro is now deprecated in favour of the
* xSemaphoreCreateBinary() function. Note that binary semaphores created using
* the vSemaphoreCreateBinary() macro are created in a state such that the
* @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
- // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
- // This is a macro so pass the variable in directly.
- vSemaphoreCreateBinary( xSemaphore );
-
- if( xSemaphore != NULL )
- {
- // The semaphore was created successfully.
- // The semaphore can now be used.
- }
- }
- </pre>
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore = NULL;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
+ * // This is a macro so pass the variable in directly.
+ * vSemaphoreCreateBinary( xSemaphore );
+ *
+ * if( xSemaphore != NULL )
+ * {
+ * // The semaphore was created successfully.
+ * // The semaphore can now be used.
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
} \
}
#endif
+/** @endcond */
/**
- * semphr. h
- * <pre>SemaphoreHandle_t xSemaphoreCreateBinary( void )</pre>
- *
* Creates a new binary semaphore instance, and returns a handle by which the
* new semaphore can be referenced.
*
* @return Handle to the created semaphore.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
- // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
- // This is a macro so pass the variable in directly.
- xSemaphore = xSemaphoreCreateBinary();
-
- if( xSemaphore != NULL )
- {
- // The semaphore was created successfully.
- // The semaphore can now be used.
- }
- }
- </pre>
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore = NULL;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
+ * // This is a macro so pass the variable in directly.
+ * xSemaphore = xSemaphoreCreateBinary();
+ *
+ * if( xSemaphore != NULL )
+ * {
+ * // The semaphore was created successfully.
+ * // The semaphore can now be used.
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#endif
/**
- * semphr. h
- * <pre>SemaphoreHandle_t xSemaphoreCreateBinaryStatic( StaticSemaphore_t *pxSemaphoreBuffer )</pre>
- *
* Creates a new binary semaphore instance, and returns a handle by which the
* new semaphore can be referenced.
*
* semaphore does not use a priority inheritance mechanism. For an alternative
* that does use priority inheritance see xSemaphoreCreateMutex().
*
- * @param pxSemaphoreBuffer Must point to a variable of type StaticSemaphore_t,
+ * @param pxStaticSemaphore Must point to a variable of type StaticSemaphore_t,
* which will then be used to hold the semaphore's data structure, removing the
* need for the memory to be allocated dynamically.
*
* returned. If pxSemaphoreBuffer is NULL then NULL is returned.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore = NULL;
- StaticSemaphore_t xSemaphoreBuffer;
-
- void vATask( void * pvParameters )
- {
- // Semaphore cannot be used before a call to xSemaphoreCreateBinary().
- // The semaphore's data structures will be placed in the xSemaphoreBuffer
- // variable, the address of which is passed into the function. The
- // function's parameter is not NULL, so the function will not attempt any
- // dynamic memory allocation, and therefore the function will not return
- // return NULL.
- xSemaphore = xSemaphoreCreateBinary( &xSemaphoreBuffer );
-
- // Rest of task code goes here.
- }
- </pre>
- * \defgroup xSemaphoreCreateBinaryStatic xSemaphoreCreateBinaryStatic
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore = NULL;
+ * StaticSemaphore_t xSemaphoreBuffer;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * // Semaphore cannot be used before a call to xSemaphoreCreateBinary().
+ * // The semaphore's data structures will be placed in the xSemaphoreBuffer
+ * // variable, the address of which is passed into the function. The
+ * // function's parameter is not NULL, so the function will not attempt any
+ * // dynamic memory allocation, and therefore the function will not return
+ * // return NULL.
+ * xSemaphore = xSemaphoreCreateBinary( &xSemaphoreBuffer );
+ *
+ * // Rest of task code goes here.
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
#endif /* configSUPPORT_STATIC_ALLOCATION */
/**
- * semphr. h
- * <pre>xSemaphoreTake(
- * SemaphoreHandle_t xSemaphore,
- * TickType_t xBlockTime
- * )</pre>
- *
* <i>Macro</i> to obtain a semaphore. The semaphore must have previously been
* created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or
* xSemaphoreCreateCounting().
* if xBlockTime expired without the semaphore becoming available.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore = NULL;
-
- // A task that creates a semaphore.
- void vATask( void * pvParameters )
- {
- // Create the semaphore to guard a shared resource.
- vSemaphoreCreateBinary( xSemaphore );
- }
-
- // A task that uses the semaphore.
- void vAnotherTask( void * pvParameters )
- {
- // ... Do other things.
-
- if( xSemaphore != NULL )
- {
- // See if we can obtain the semaphore. If the semaphore is not available
- // wait 10 ticks to see if it becomes free.
- if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
- {
- // We were able to obtain the semaphore and can now access the
- // shared resource.
-
- // ...
-
- // We have finished accessing the shared resource. Release the
- // semaphore.
- xSemaphoreGive( xSemaphore );
- }
- else
- {
- // We could not obtain the semaphore and can therefore not access
- // the shared resource safely.
- }
- }
- }
- </pre>
- * \defgroup xSemaphoreTake xSemaphoreTake
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore = NULL;
+ *
+ * // A task that creates a semaphore.
+ * void vATask( void * pvParameters )
+ * {
+ * // Create the semaphore to guard a shared resource.
+ * vSemaphoreCreateBinary( xSemaphore );
+ * }
+ *
+ * // A task that uses the semaphore.
+ * void vAnotherTask( void * pvParameters )
+ * {
+ * // ... Do other things.
+ *
+ * if( xSemaphore != NULL )
+ * {
+ * // See if we can obtain the semaphore. If the semaphore is not available
+ * // wait 10 ticks to see if it becomes free.
+ * if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
+ * {
+ * // We were able to obtain the semaphore and can now access the
+ * // shared resource.
+ *
+ * // ...
+ *
+ * // We have finished accessing the shared resource. Release the
+ * // semaphore.
+ * xSemaphoreGive( xSemaphore );
+ * }
+ * else
+ * {
+ * // We could not obtain the semaphore and can therefore not access
+ * // the shared resource safely.
+ * }
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )
/**
- * semphr. h
- * xSemaphoreTakeRecursive(
- * SemaphoreHandle_t xMutex,
- * TickType_t xBlockTime
- * )
- *
* <i>Macro</i> to recursively obtain, or 'take', a mutex type semaphore.
* The mutex must have previously been created using a call to
* xSemaphoreCreateRecursiveMutex();
* expired without the semaphore becoming available.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
- // Create the mutex to guard a shared resource.
- xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
- // ... Do other things.
-
- if( xMutex != NULL )
- {
- // See if we can obtain the mutex. If the mutex is not available
- // wait 10 ticks to see if it becomes free.
- if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
- {
- // We were able to obtain the mutex and can now access the
- // shared resource.
-
- // ...
- // For some reason due to the nature of the code further calls to
- // xSemaphoreTakeRecursive() are made on the same mutex. In real
- // code these would not be just sequential calls as this would make
- // no sense. Instead the calls are likely to be buried inside
- // a more complex call structure.
- xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
- xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-
- // The mutex has now been 'taken' three times, so will not be
- // available to another task until it has also been given back
- // three times. Again it is unlikely that real code would have
- // these calls sequentially, but instead buried in a more complex
- // call structure. This is just for illustrative purposes.
- xSemaphoreGiveRecursive( xMutex );
- xSemaphoreGiveRecursive( xMutex );
- xSemaphoreGiveRecursive( xMutex );
-
- // Now the mutex can be taken by other tasks.
- }
- else
- {
- // We could not obtain the mutex and can therefore not access
- // the shared resource safely.
- }
- }
- }
- </pre>
- * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive
+ * @code{c}
+ * SemaphoreHandle_t xMutex = NULL;
+ *
+ * // A task that creates a mutex.
+ * void vATask( void * pvParameters )
+ * {
+ * // Create the mutex to guard a shared resource.
+ * xMutex = xSemaphoreCreateRecursiveMutex();
+ * }
+ *
+ * // A task that uses the mutex.
+ * void vAnotherTask( void * pvParameters )
+ * {
+ * // ... Do other things.
+ *
+ * if( xMutex != NULL )
+ * {
+ * // See if we can obtain the mutex. If the mutex is not available
+ * // wait 10 ticks to see if it becomes free.
+ * if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
+ * {
+ * // We were able to obtain the mutex and can now access the
+ * // shared resource.
+ *
+ * // ...
+ * // For some reason due to the nature of the code further calls to
+ * // xSemaphoreTakeRecursive() are made on the same mutex. In real
+ * // code these would not be just sequential calls as this would make
+ * // no sense. Instead the calls are likely to be buried inside
+ * // a more complex call structure.
+ * xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
+ * xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
+ *
+ * // The mutex has now been 'taken' three times, so will not be
+ * // available to another task until it has also been given back
+ * // three times. Again it is unlikely that real code would have
+ * // these calls sequentially, but instead buried in a more complex
+ * // call structure. This is just for illustrative purposes.
+ * xSemaphoreGiveRecursive( xMutex );
+ * xSemaphoreGiveRecursive( xMutex );
+ * xSemaphoreGiveRecursive( xMutex );
+ *
+ * // Now the mutex can be taken by other tasks.
+ * }
+ * else
+ * {
+ * // We could not obtain the mutex and can therefore not access
+ * // the shared resource safely.
+ * }
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) )
-
+/** @cond */
/*
* xSemaphoreAltTake() is an alternative version of xSemaphoreTake().
*
* sacrifices execution speed to ensure better interrupt responsiveness.
*/
#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )
+/** @endcond */
/**
- * semphr. h
- * <pre>xSemaphoreGive( SemaphoreHandle_t xSemaphore )</pre>
- *
* <i>Macro</i> to release a semaphore. The semaphore must have previously been
* created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or
* xSemaphoreCreateCounting(). and obtained using sSemaphoreTake().
* semaphore was not first obtained correctly.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
- // Create the semaphore to guard a shared resource.
- vSemaphoreCreateBinary( xSemaphore );
-
- if( xSemaphore != NULL )
- {
- if( xSemaphoreGive( xSemaphore ) != pdTRUE )
- {
- // We would expect this call to fail because we cannot give
- // a semaphore without first "taking" it!
- }
-
- // Obtain the semaphore - don't block if the semaphore is not
- // immediately available.
- if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )
- {
- // We now have the semaphore and can access the shared resource.
-
- // ...
-
- // We have finished accessing the shared resource so can free the
- // semaphore.
- if( xSemaphoreGive( xSemaphore ) != pdTRUE )
- {
- // We would not expect this call to fail because we must have
- // obtained the semaphore to get here.
- }
- }
- }
- }
- </pre>
- * \defgroup xSemaphoreGive xSemaphoreGive
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore = NULL;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * // Create the semaphore to guard a shared resource.
+ * vSemaphoreCreateBinary( xSemaphore );
+ *
+ * if( xSemaphore != NULL )
+ * {
+ * if( xSemaphoreGive( xSemaphore ) != pdTRUE )
+ * {
+ * // We would expect this call to fail because we cannot give
+ * // a semaphore without first "taking" it!
+ * }
+ *
+ * // Obtain the semaphore - don't block if the semaphore is not
+ * // immediately available.
+ * if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )
+ * {
+ * // We now have the semaphore and can access the shared resource.
+ *
+ * // ...
+ *
+ * // We have finished accessing the shared resource so can free the
+ * // semaphore.
+ * if( xSemaphoreGive( xSemaphore ) != pdTRUE )
+ * {
+ * // We would not expect this call to fail because we must have
+ * // obtained the semaphore to get here.
+ * }
+ * }
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
/**
- * semphr. h
- * <pre>xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )</pre>
- *
* <i>Macro</i> to recursively release, or 'give', a mutex type semaphore.
* The mutex must have previously been created using a call to
* xSemaphoreCreateRecursiveMutex();
* @return pdTRUE if the semaphore was given.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
- // Create the mutex to guard a shared resource.
- xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
- // ... Do other things.
-
- if( xMutex != NULL )
- {
- // See if we can obtain the mutex. If the mutex is not available
- // wait 10 ticks to see if it becomes free.
- if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )
- {
- // We were able to obtain the mutex and can now access the
- // shared resource.
-
- // ...
- // For some reason due to the nature of the code further calls to
- // xSemaphoreTakeRecursive() are made on the same mutex. In real
- // code these would not be just sequential calls as this would make
- // no sense. Instead the calls are likely to be buried inside
- // a more complex call structure.
- xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
- xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-
- // The mutex has now been 'taken' three times, so will not be
- // available to another task until it has also been given back
- // three times. Again it is unlikely that real code would have
- // these calls sequentially, it would be more likely that the calls
- // to xSemaphoreGiveRecursive() would be called as a call stack
- // unwound. This is just for demonstrative purposes.
- xSemaphoreGiveRecursive( xMutex );
- xSemaphoreGiveRecursive( xMutex );
- xSemaphoreGiveRecursive( xMutex );
-
- // Now the mutex can be taken by other tasks.
- }
- else
- {
- // We could not obtain the mutex and can therefore not access
- // the shared resource safely.
- }
- }
- }
- </pre>
- * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive
+ * @code{c}
+ * SemaphoreHandle_t xMutex = NULL;
+ *
+ * // A task that creates a mutex.
+ * void vATask( void * pvParameters )
+ * {
+ * // Create the mutex to guard a shared resource.
+ * xMutex = xSemaphoreCreateRecursiveMutex();
+ * }
+ *
+ * // A task that uses the mutex.
+ * void vAnotherTask( void * pvParameters )
+ * {
+ * // ... Do other things.
+ *
+ * if( xMutex != NULL )
+ * {
+ * // See if we can obtain the mutex. If the mutex is not available
+ * // wait 10 ticks to see if it becomes free.
+ * if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )
+ * {
+ * // We were able to obtain the mutex and can now access the
+ * // shared resource.
+ *
+ * // ...
+ * // For some reason due to the nature of the code further calls to
+ * // xSemaphoreTakeRecursive() are made on the same mutex. In real
+ * // code these would not be just sequential calls as this would make
+ * // no sense. Instead the calls are likely to be buried inside
+ * // a more complex call structure.
+ * xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
+ * xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
+ *
+ * // The mutex has now been 'taken' three times, so will not be
+ * // available to another task until it has also been given back
+ * // three times. Again it is unlikely that real code would have
+ * // these calls sequentially, it would be more likely that the calls
+ * // to xSemaphoreGiveRecursive() would be called as a call stack
+ * // unwound. This is just for demonstrative purposes.
+ * xSemaphoreGiveRecursive( xMutex );
+ * xSemaphoreGiveRecursive( xMutex );
+ * xSemaphoreGiveRecursive( xMutex );
+ *
+ * // Now the mutex can be taken by other tasks.
+ * }
+ * else
+ * {
+ * // We could not obtain the mutex and can therefore not access
+ * // the shared resource safely.
+ * }
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) )
+/** @cond */
/*
* xSemaphoreAltGive() is an alternative version of xSemaphoreGive().
*
*/
#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
+/** @endcond */
+
/**
- * semphr. h
- * <pre>
- xSemaphoreGiveFromISR(
- SemaphoreHandle_t xSemaphore,
- BaseType_t *pxHigherPriorityTaskWoken
- )</pre>
- *
* <i>Macro</i> to release a semaphore. The semaphore must have previously been
* created with a call to vSemaphoreCreateBinary() or xSemaphoreCreateCounting().
*
* @param xSemaphore A handle to the semaphore being released. This is the
* handle returned when the semaphore was created.
*
- * @param pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set
+ * @param[out] pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if giving the semaphore caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xSemaphoreGiveFromISR() sets this value to pdTRUE then
* @return pdTRUE if the semaphore was successfully given, otherwise errQUEUE_FULL.
*
* Example usage:
- <pre>
- \#define LONG_TIME 0xffff
- \#define TICKS_TO_WAIT 10
- SemaphoreHandle_t xSemaphore = NULL;
-
- // Repetitive task.
- void vATask( void * pvParameters )
- {
- for( ;; )
- {
- // We want this task to run every 10 ticks of a timer. The semaphore
- // was created before this task was started.
-
- // Block waiting for the semaphore to become available.
- if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
- {
- // It is time to execute.
-
- // ...
-
- // We have finished our task. Return to the top of the loop where
- // we will block on the semaphore until it is time to execute
- // again. Note when using the semaphore for synchronisation with an
- // ISR in this manner there is no need to 'give' the semaphore back.
- }
- }
- }
-
- // Timer ISR
- void vTimerISR( void * pvParameters )
- {
- static uint8_t ucLocalTickCount = 0;
- static BaseType_t xHigherPriorityTaskWoken;
-
- // A timer tick has occurred.
-
- // ... Do other time functions.
-
- // Is it time for vATask () to run?
- xHigherPriorityTaskWoken = pdFALSE;
- ucLocalTickCount++;
- if( ucLocalTickCount >= TICKS_TO_WAIT )
- {
- // Unblock the task by releasing the semaphore.
- xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
-
- // Reset the count so we release the semaphore again in 10 ticks time.
- ucLocalTickCount = 0;
- }
-
- if( xHigherPriorityTaskWoken != pdFALSE )
- {
- // We can force a context switch here. Context switching from an
- // ISR uses port specific syntax. Check the demo task for your port
- // to find the syntax required.
- }
- }
- </pre>
- * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR
+ * @code{c}
+ * \#define LONG_TIME 0xffff
+ * \#define TICKS_TO_WAIT 10
+ * SemaphoreHandle_t xSemaphore = NULL;
+ *
+ * // Repetitive task.
+ * void vATask( void * pvParameters )
+ * {
+ * for( ;; )
+ * {
+ * // We want this task to run every 10 ticks of a timer. The semaphore
+ * // was created before this task was started.
+ *
+ * // Block waiting for the semaphore to become available.
+ * if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
+ * {
+ * // It is time to execute.
+ *
+ * // ...
+ *
+ * // We have finished our task. Return to the top of the loop where
+ * // we will block on the semaphore until it is time to execute
+ * // again. Note when using the semaphore for synchronisation with an
+ * // ISR in this manner there is no need to 'give' the semaphore back.
+ * }
+ * }
+ * }
+ *
+ * // Timer ISR
+ * void vTimerISR( void * pvParameters )
+ * {
+ * static uint8_t ucLocalTickCount = 0;
+ * static BaseType_t xHigherPriorityTaskWoken;
+ *
+ * // A timer tick has occurred.
+ *
+ * // ... Do other time functions.
+ *
+ * // Is it time for vATask () to run?
+ * xHigherPriorityTaskWoken = pdFALSE;
+ * ucLocalTickCount++;
+ * if( ucLocalTickCount >= TICKS_TO_WAIT )
+ * {
+ * // Unblock the task by releasing the semaphore.
+ * xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
+ *
+ * // Reset the count so we release the semaphore again in 10 ticks time.
+ * ucLocalTickCount = 0;
+ * }
+ *
+ * if( xHigherPriorityTaskWoken != pdFALSE )
+ * {
+ * // We can force a context switch here. Context switching from an
+ * // ISR uses port specific syntax. Check the demo task for your port
+ * // to find the syntax required.
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) )
/**
- * semphr. h
- * <pre>
- xSemaphoreTakeFromISR(
- SemaphoreHandle_t xSemaphore,
- BaseType_t *pxHigherPriorityTaskWoken
- )</pre>
- *
* <i>Macro</i> to take a semaphore from an ISR. The semaphore must have
* previously been created with a call to vSemaphoreCreateBinary() or
* xSemaphoreCreateCounting().
* @param xSemaphore A handle to the semaphore being taken. This is the
* handle returned when the semaphore was created.
*
- * @param pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set
+ * @param[out] pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if taking the semaphore caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xSemaphoreTakeFromISR() sets this value to pdTRUE then
#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )
/**
- * semphr. h
- * <pre>SemaphoreHandle_t xSemaphoreCreateMutex( void )</pre>
- *
* <i>Macro</i> that implements a mutex semaphore by using the existing queue
* mechanism.
*
* data structures then NULL is returned.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
- // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
- // This is a macro so pass the variable in directly.
- xSemaphore = xSemaphoreCreateMutex();
-
- if( xSemaphore != NULL )
- {
- // The semaphore was created successfully.
- // The semaphore can now be used.
- }
- }
- </pre>
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
+ * // This is a macro so pass the variable in directly.
+ * xSemaphore = xSemaphoreCreateMutex();
+ *
+ * if( xSemaphore != NULL )
+ * {
+ * // The semaphore was created successfully.
+ * // The semaphore can now be used.
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#endif
/**
- * semphr. h
- * <pre>SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSemaphore_t *pxMutexBuffer )</pre>
- *
* Creates a new mutex type semaphore instance, and returns a handle by which
* the new mutex can be referenced.
*
* mutex is returned. If pxMutexBuffer was NULL then NULL is returned.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore;
- StaticSemaphore_t xMutexBuffer;
-
- void vATask( void * pvParameters )
- {
- // A mutex cannot be used before it has been created. xMutexBuffer is
- // into xSemaphoreCreateMutexStatic() so no dynamic memory allocation is
- // attempted.
- xSemaphore = xSemaphoreCreateMutexStatic( &xMutexBuffer );
-
- // As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
- // so there is no need to check it.
- }
- </pre>
- * \defgroup xSemaphoreCreateMutexStatic xSemaphoreCreateMutexStatic
+ * @code
+ * SemaphoreHandle_t xSemaphore;
+ * StaticSemaphore_t xMutexBuffer;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * // A mutex cannot be used before it has been created. xMutexBuffer is
+ * // into xSemaphoreCreateMutexStatic() so no dynamic memory allocation is
+ * // attempted.
+ * xSemaphore = xSemaphoreCreateMutexStatic( &xMutexBuffer );
+ *
+ * // As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
+ * // so there is no need to check it.
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
/**
- * semphr. h
- * <pre>SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )</pre>
- *
* Creates a new recursive mutex type semaphore instance, and returns a handle
* by which the new recursive mutex can be referenced.
*
* SemaphoreHandle_t.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
- // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
- // This is a macro so pass the variable in directly.
- xSemaphore = xSemaphoreCreateRecursiveMutex();
-
- if( xSemaphore != NULL )
- {
- // The semaphore was created successfully.
- // The semaphore can now be used.
- }
- }
- </pre>
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
+ * // This is a macro so pass the variable in directly.
+ * xSemaphore = xSemaphoreCreateRecursiveMutex();
+ *
+ * if( xSemaphore != NULL )
+ * {
+ * // The semaphore was created successfully.
+ * // The semaphore can now be used.
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) )
#endif
/**
- * semphr. h
- * <pre>SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic( StaticSemaphore_t *pxMutexBuffer )</pre>
- *
* Creates a new recursive mutex type semaphore instance, and returns a handle
* by which the new recursive mutex can be referenced.
*
* semaphore and another always 'takes' the semaphore) and from within interrupt
* service routines.
*
- * @param pxMutexBuffer Must point to a variable of type StaticSemaphore_t,
+ * @param pxStaticSemaphore Must point to a variable of type StaticSemaphore_t,
* which will then be used to hold the recursive mutex's data structure,
* removing the need for the memory to be allocated dynamically.
*
* returned.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore;
- StaticSemaphore_t xMutexBuffer;
-
- void vATask( void * pvParameters )
- {
- // A recursive semaphore cannot be used before it is created. Here a
- // recursive mutex is created using xSemaphoreCreateRecursiveMutexStatic().
- // The address of xMutexBuffer is passed into the function, and will hold
- // the mutexes data structures - so no dynamic memory allocation will be
- // attempted.
- xSemaphore = xSemaphoreCreateRecursiveMutexStatic( &xMutexBuffer );
-
- // As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
- // so there is no need to check it.
- }
- </pre>
- * \defgroup xSemaphoreCreateRecursiveMutexStatic xSemaphoreCreateRecursiveMutexStatic
+ * @code
+ * SemaphoreHandle_t xSemaphore;
+ * StaticSemaphore_t xMutexBuffer;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * // A recursive semaphore cannot be used before it is created. Here a
+ * // recursive mutex is created using xSemaphoreCreateRecursiveMutexStatic().
+ * // The address of xMutexBuffer is passed into the function, and will hold
+ * // the mutexes data structures - so no dynamic memory allocation will be
+ * // attempted.
+ * xSemaphore = xSemaphoreCreateRecursiveMutexStatic( &xMutexBuffer );
+ *
+ * // As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
+ * // so there is no need to check it.
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */
/**
- * semphr. h
- * <pre>SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount )</pre>
- *
* Creates a new counting semaphore instance, and returns a handle by which the
* new counting semaphore can be referenced.
*
* created.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
- SemaphoreHandle_t xSemaphore = NULL;
-
- // Semaphore cannot be used before a call to xSemaphoreCreateCounting().
- // The max value to which the semaphore can count should be 10, and the
- // initial value assigned to the count should be 0.
- xSemaphore = xSemaphoreCreateCounting( 10, 0 );
-
- if( xSemaphore != NULL )
- {
- // The semaphore was created successfully.
- // The semaphore can now be used.
- }
- }
- </pre>
- * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * SemaphoreHandle_t xSemaphore = NULL;
+ *
+ * // Semaphore cannot be used before a call to xSemaphoreCreateCounting().
+ * // The max value to which the semaphore can count should be 10, and the
+ * // initial value assigned to the count should be 0.
+ * xSemaphore = xSemaphoreCreateCounting( 10, 0 );
+ *
+ * if( xSemaphore != NULL )
+ * {
+ * // The semaphore was created successfully.
+ * // The semaphore can now be used.
+ * }
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#endif
/**
- * semphr. h
- * <pre>SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer )</pre>
- *
* Creates a new counting semaphore instance, and returns a handle by which the
* new counting semaphore can be referenced.
*
* then NULL is returned.
*
* Example usage:
- <pre>
- SemaphoreHandle_t xSemaphore;
- StaticSemaphore_t xSemaphoreBuffer;
-
- void vATask( void * pvParameters )
- {
- SemaphoreHandle_t xSemaphore = NULL;
-
- // Counting semaphore cannot be used before they have been created. Create
- // a counting semaphore using xSemaphoreCreateCountingStatic(). The max
- // value to which the semaphore can count is 10, and the initial value
- // assigned to the count will be 0. The address of xSemaphoreBuffer is
- // passed in and will be used to hold the semaphore structure, so no dynamic
- // memory allocation will be used.
- xSemaphore = xSemaphoreCreateCounting( 10, 0, &xSemaphoreBuffer );
-
- // No memory allocation was attempted so xSemaphore cannot be NULL, so there
- // is no need to check its value.
- }
- </pre>
- * \defgroup xSemaphoreCreateCountingStatic xSemaphoreCreateCountingStatic
+ * @code{c}
+ * SemaphoreHandle_t xSemaphore;
+ * StaticSemaphore_t xSemaphoreBuffer;
+ *
+ * void vATask( void * pvParameters )
+ * {
+ * SemaphoreHandle_t xSemaphore = NULL;
+ *
+ * // Counting semaphore cannot be used before they have been created. Create
+ * // a counting semaphore using xSemaphoreCreateCountingStatic(). The max
+ * // value to which the semaphore can count is 10, and the initial value
+ * // assigned to the count will be 0. The address of xSemaphoreBuffer is
+ * // passed in and will be used to hold the semaphore structure, so no dynamic
+ * // memory allocation will be used.
+ * xSemaphore = xSemaphoreCreateCounting( 10, 0, &xSemaphoreBuffer );
+ *
+ * // No memory allocation was attempted so xSemaphore cannot be NULL, so there
+ * // is no need to check its value.
+ * }
+ * @endcode
* \ingroup Semaphores
*/
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
#endif /* configSUPPORT_STATIC_ALLOCATION */
/**
- * semphr. h
- * <pre>void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );</pre>
- *
* Delete a semaphore. This function must be used with care. For example,
* do not delete a mutex type semaphore if the mutex is held by a task.
*
* @param xSemaphore A handle to the semaphore to be deleted.
*
- * \defgroup vSemaphoreDelete vSemaphoreDelete
* \ingroup Semaphores
*/
#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) )
/**
- * semphr.h
- * <pre>TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );</pre>
- *
* If xMutex is indeed a mutex type semaphore, return the current mutex holder.
* If xMutex is not a mutex type semaphore, or the mutex is available (not held
* by a task), return NULL.
#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) )
/**
- * semphr.h
- * <pre>UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );</pre>
- *
* If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns
* its current count value. If the semaphore is a binary semaphore then
* uxSemaphoreGetCount() returns 1 if the semaphore is available, and 0 if the