* \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary\r
* \ingroup Semaphores\r
*/\r
-#define vSemaphoreCreateBinary( xSemaphore ) \\r
- { \\r
- ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, NULL, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \\r
- if( ( xSemaphore ) != NULL ) \\r
- { \\r
- ( void ) xSemaphoreGive( ( xSemaphore ) ); \\r
- } \\r
- }\r
+#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
+ #define vSemaphoreCreateBinary( xSemaphore ) \\r
+ { \\r
+ ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \\r
+ if( ( xSemaphore ) != NULL ) \\r
+ { \\r
+ ( void ) xSemaphoreGive( ( xSemaphore ) ); \\r
+ } \\r
+ }\r
+#endif\r
\r
/**\r
* semphr. h\r
* automatically dynamically allocated inside the xSemaphoreCreateBinary()\r
* function. (see http://www.freertos.org/a00111.html). If a binary semaphore\r
* is created using xSemaphoreCreateBinaryStatic() then the application writer\r
- * can instead optionally provide the memory that will get used by the binary\r
- * semaphore. xSemaphoreCreateBinaryStatic() therefore allows a binary\r
- * semaphore to be created without using any dynamic memory allocation.\r
+ * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a\r
+ * binary semaphore to be created without using any dynamic memory allocation.\r
*\r
* The old vSemaphoreCreateBinary() macro is now deprecated in favour of this\r
* xSemaphoreCreateBinary() function. Note that binary semaphores created using\r
* \defgroup xSemaphoreCreateBinary xSemaphoreCreateBinary\r
* \ingroup Semaphores\r
*/\r
-#define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, NULL, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
+#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
+ #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
+#endif\r
\r
/**\r
* semphr. h\r
* automatically dynamically allocated inside the xSemaphoreCreateBinary()\r
* function. (see http://www.freertos.org/a00111.html). If a binary semaphore\r
* is created using xSemaphoreCreateBinaryStatic() then the application writer\r
- * can instead optionally provide the memory that will get used by the binary\r
- * semaphore. xSemaphoreCreateBinaryStatic() therefore allows a binary\r
- * semaphore to be created without using any dynamic memory allocation.\r
+ * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a\r
+ * binary semaphore to be created without using any dynamic memory allocation.\r
*\r
* This type of semaphore can be used for pure synchronisation between tasks or\r
* between an interrupt and a task. The semaphore need not be given back once\r
* semaphore does not use a priority inheritance mechanism. For an alternative\r
* that does use priority inheritance see xSemaphoreCreateMutex().\r
*\r
- * @param pxSemaphoreBuffer If pxSemaphoreBuffer is NULL then the memory\r
- * required to hold the semaphore's data structures will be allocated\r
- * dynamically, just as when a semaphore is created using\r
- * xSemaphoreCreateBinary(). If pxSemaphoreBuffer is not NULL then it must\r
- * point to a variable of type StaticSemaphore_t, which will then be used to\r
- * hold the semaphore's data structure, removing the need for the memory to be\r
- * allocated dynamically.\r
- *\r
- * @return If pxSemaphoreBuffer is not NULL then the function will not attempt\r
- * any dynamic memory allocation, and a handle to the created semaphore will\r
- * always be returned. If pxSemaphoreBuffer is NULL then the function will\r
- * attempt to dynamically allocate the memory required to hold the semaphore's\r
- * data structures. In this case, if the allocation succeeds then a handle to\r
- * the created semaphore will be returned, and if the allocation fails NULL will\r
- * be returned.\r
+ * @param pxSemaphoreBuffer Must point to a variable of type StaticSemaphore_t,\r
+ * which will then be used to hold the semaphore's data structure, removing the\r
+ * need for the memory to be allocated dynamically.\r
+ *\r
+ * @return If the semaphore is created then a handle to the created semaphore is\r
+ * returned. If pxSemaphoreBuffer is NULL then NULL is returned.\r
*\r
* Example usage:\r
<pre>\r
* \ingroup Semaphores\r
*/\r
#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
- #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
+ #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
#endif /* configSUPPORT_STATIC_ALLOCATION */\r
\r
/**\r
* using xSemaphoreCreateMutex() then the required memory is automatically\r
* dynamically allocated inside the xSemaphoreCreateMutex() function. (see\r
* http://www.freertos.org/a00111.html). If a mutex is created using\r
- * xSemaphoreCreateMutexStatic() then the application writer can instead\r
- * optionally provide the memory that will get used by the mutex.\r
- * xSemaphoreCreateMutexStatic() therefore allows a mutex to be created without\r
- * using any dynamic memory allocation.\r
+ * xSemaphoreCreateMutexStatic() then the application writer must provided the\r
+ * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created\r
+ * without using any dynamic memory allocation.\r
*\r
* Mutexes created using this function can be accessed using the xSemaphoreTake()\r
* and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and\r
* \defgroup xSemaphoreCreateMutex xSemaphoreCreateMutex\r
* \ingroup Semaphores\r
*/\r
-#define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX, NULL )\r
+#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
+ #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX )\r
+#endif\r
\r
/**\r
* semphr. h\r
* using xSemaphoreCreateMutex() then the required memory is automatically\r
* dynamically allocated inside the xSemaphoreCreateMutex() function. (see\r
* http://www.freertos.org/a00111.html). If a mutex is created using\r
- * xSemaphoreCreateMutexStatic() then the application writer can instead\r
- * optionally provide the memory that will get used by the mutex.\r
- * xSemaphoreCreateMutexStatic() therefore allows a mutex to be created without\r
- * using any dynamic memory allocation.\r
+ * xSemaphoreCreateMutexStatic() then the application writer must provided the\r
+ * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created\r
+ * without using any dynamic memory allocation.\r
*\r
* Mutexes created using this function can be accessed using the xSemaphoreTake()\r
* and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and\r
* semaphore and another always 'takes' the semaphore) and from within interrupt\r
* service routines.\r
*\r
- * @param pxMutexBuffer If pxMutexBuffer is NULL then the memory required to\r
- * hold the mutex's data structures will be allocated dynamically, just as when\r
- * a mutex is created using xSemaphoreCreateMutex(). If pxMutexBuffer is not\r
- * NULL then it must point to a variable of type StaticSemaphore_t, which will\r
- * then be used to hold the mutex's data structure, removing the need for\r
+ * @param pxMutexBuffer Must point to a variable of type StaticSemaphore_t,\r
+ * which will be used to hold the mutex's data structure, removing the need for\r
* the memory to be allocated dynamically.\r
*\r
* @return If the mutex was successfully created then a handle to the created\r
- * mutex is returned. If pxMutexBuffer was NULL, and there was not enough\r
- * heap to allocate the mutex data structures, then NULL is returned.\r
+ * mutex is returned. If pxMutexBuffer was NULL then NULL is returned.\r
*\r
* Example usage:\r
<pre>\r
* \ingroup Semaphores\r
*/\r
#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
- #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutex( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) )\r
+ #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) )\r
#endif /* configSUPPORT_STATIC_ALLOCATION */\r
\r
\r
* automatically dynamically allocated inside the\r
* xSemaphoreCreateRecursiveMutex() function. (see\r
* http://www.freertos.org/a00111.html). If a recursive mutex is created using\r
- * xSemaphoreCreateRecursiveMutexStatic() then the application writer can\r
- * instead optionally provide the memory that will get used by the mutex.\r
+ * xSemaphoreCreateRecursiveMutexStatic() then the application writer must\r
+ * provide the memory that will get used by the mutex.\r
* xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to\r
* be created without using any dynamic memory allocation.\r
*\r
* \defgroup xSemaphoreCreateRecursiveMutex xSemaphoreCreateRecursiveMutex\r
* \ingroup Semaphores\r
*/\r
-#define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX, NULL )\r
+#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
+ #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX )\r
+#endif\r
\r
/**\r
* semphr. h\r
* automatically dynamically allocated inside the\r
* xSemaphoreCreateRecursiveMutex() function. (see\r
* http://www.freertos.org/a00111.html). If a recursive mutex is created using\r
- * xSemaphoreCreateRecursiveMutexStatic() then the application writer can\r
- * instead optionally provide the memory that will get used by the mutex.\r
+ * xSemaphoreCreateRecursiveMutexStatic() then the application writer must\r
+ * provide the memory that will get used by the mutex.\r
* xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to\r
* be created without using any dynamic memory allocation.\r
*\r
* semaphore and another always 'takes' the semaphore) and from within interrupt\r
* service routines.\r
*\r
- * @param pxMutexBuffer If pxMutexBuffer is NULL then the memory required to\r
- * hold the recursive mutex's data structures will be allocated dynamically,\r
- * just as when a recursive mutex is created using\r
- * xSemaphoreCreateRecursiveMutex(). If pxMutexBuffer is not NULL then it must\r
- * point to a variable of type StaticSemaphore_t, which will then be used to\r
- * hold the recursive mutex's data structure, removing the need for the memory\r
- * to be allocated dynamically.\r
+ * @param pxMutexBuffer Must point to a variable of type StaticSemaphore_t,\r
+ * which will then be used to hold the recursive mutex's data structure,\r
+ * removing the need for the memory to be allocated dynamically.\r
*\r
* @return If the recursive mutex was successfully created then a handle to the\r
- * created recursive mutex is returned. If pxMutexBuffer was NULL, and there\r
- * was not enough heap to allocate the mutex data structures, then NULL is\r
+ * created recursive mutex is returned. If pxMutexBuffer was NULL then NULL is\r
* returned.\r
*\r
* Example usage:\r
* \ingroup Semaphores\r
*/\r
#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
- #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore )\r
+ #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore )\r
#endif /* configSUPPORT_STATIC_ALLOCATION */\r
\r
/**\r
* Creates a new counting semaphore instance, and returns a handle by which the\r
* new counting semaphore can be referenced.\r
*\r
+ * In many usage scenarios it is faster and more memory efficient to use a\r
+ * direct to task notification in place of a counting semaphore!\r
+ * http://www.freertos.org/RTOS-task-notifications.html\r
+ *\r
* Internally, within the FreeRTOS implementation, counting semaphores use a\r
* block of memory, in which the counting semaphore structure is stored. If a\r
* counting semaphore is created using xSemaphoreCreateCounting() then the\r
* \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting\r
* \ingroup Semaphores\r
*/\r
-#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ), ( NULL ) )\r
+#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
+ #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) )\r
+#endif\r
\r
/**\r
* semphr. h\r
* Creates a new counting semaphore instance, and returns a handle by which the\r
* new counting semaphore can be referenced.\r
*\r
+ * In many usage scenarios it is faster and more memory efficient to use a\r
+ * direct to task notification in place of a counting semaphore!\r
+ * http://www.freertos.org/RTOS-task-notifications.html\r
+ *\r
* Internally, within the FreeRTOS implementation, counting semaphores use a\r
* block of memory, in which the counting semaphore structure is stored. If a\r
* counting semaphore is created using xSemaphoreCreateCounting() then the\r
* required memory is automatically dynamically allocated inside the\r
* xSemaphoreCreateCounting() function. (see\r
* http://www.freertos.org/a00111.html). If a counting semaphore is created\r
- * using xSemaphoreCreateCountingStatic() then the application writer can\r
- * instead optionally provide the memory that will get used by the counting\r
- * semaphore. xSemaphoreCreateCountingStatic() therefore allows a counting\r
- * semaphore to be created without using any dynamic memory allocation.\r
+ * using xSemaphoreCreateCountingStatic() then the application writer must\r
+ * provide the memory. xSemaphoreCreateCountingStatic() therefore allows a\r
+ * counting semaphore to be created without using any dynamic memory allocation.\r
*\r
* Counting semaphores are typically used for two things:\r
*\r
* @param uxInitialCount The count value assigned to the semaphore when it is\r
* created.\r
*\r
- * @param pxSemaphoreBuffer If pxSemaphoreBuffer is NULL then the memory\r
- * required to hold the semaphore's data structures will be allocated\r
- * dynamically, just as when a counting semaphore is created using\r
- * xSemaphoreCreateCounting(). If pxSemaphoreBuffer is not NULL then it must\r
- * point to a variable of type StaticSemaphore_t, which will then be used to\r
- * hold the semaphore's data structure, removing the need for the memory\r
- * to be allocated dynamically.\r
+ * @param pxSemaphoreBuffer Must point to a variable of type StaticSemaphore_t,\r
+ * which will then be used to hold the semaphore's data structure, removing the\r
+ * need for the memory to be allocated dynamically.\r
*\r
* @return If the counting semaphore was successfully created then a handle to\r
- * the created counting semaphore is returned. If pxSemaphoreBuffer was NULL,\r
- * and there was not enough heap to allocate the counting semaphore data\r
- * structures, then NULL is returned.\r
+ * the created counting semaphore is returned. If pxSemaphoreBuffer was NULL\r
+ * then NULL is returned.\r
*\r
* Example usage:\r
<pre>\r
* \ingroup Semaphores\r
*/\r
#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
- #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) )\r
+ #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) )\r
#endif /* configSUPPORT_STATIC_ALLOCATION */\r
\r
/**\r
\r
/**\r
* semphr.h\r
- * <pre>TaskHandle_t xSemaphoreGetCount( SemaphoreHandle_t xMutex );</pre>\r
+ * <pre>UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xMutex );</pre>\r
*\r
- * If the semaphore is a counting semaphore then xSemaphoreGetCount() returns\r
+ * If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns\r
* its current count value. If the semaphore is a binary semaphore then\r
- * xSemaphoreGetCount() returns 1 if the semaphore is available, and 0 if the\r
+ * uxSemaphoreGetCount() returns 1 if the semaphore is available, and 0 if the\r
* semaphore is not available.\r
*\r
*/\r