\r
#include "queue.h"\r
\r
-typedef xQueueHandle xSemaphoreHandle;\r
+typedef QueueHandle_t SemaphoreHandle_t;\r
\r
-#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( unsigned char ) 1U )\r
-#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned char ) 0U )\r
-#define semGIVE_BLOCK_TIME ( ( portTickType ) 0U )\r
+#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U )\r
+#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U )\r
+#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U )\r
\r
\r
/**\r
* semphr. h\r
- * <pre>vSemaphoreCreateBinary( xSemaphoreHandle xSemaphore )</pre>\r
+ * <pre>vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )</pre>\r
*\r
* This old vSemaphoreCreateBinary() macro is now deprecated in favour of the\r
* xSemaphoreCreateBinary() function. Note that binary semaphores created using\r
* semaphore does not use a priority inheritance mechanism. For an alternative\r
* that does use priority inheritance see xSemaphoreCreateMutex().\r
*\r
- * @param xSemaphore Handle to the created semaphore. Should be of type xSemaphoreHandle.\r
+ * @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t.\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xSemaphore = NULL;\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
\r
void vATask( void * pvParameters )\r
{\r
* \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary\r
* \ingroup Semaphores\r
*/\r
-#define vSemaphoreCreateBinary( xSemaphore ) \\r
- { \\r
- ( xSemaphore ) = xQueueGenericCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \\r
- if( ( xSemaphore ) != NULL ) \\r
- { \\r
- ( void ) xSemaphoreGive( ( xSemaphore ) ); \\r
- } \\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
\r
/**\r
* semphr. h\r
- * <pre>xSemaphoreHandle xSemaphoreCreateBinary( void )</pre>\r
+ * <pre>SemaphoreHandle_t xSemaphoreCreateBinary( void )</pre>\r
*\r
* The old vSemaphoreCreateBinary() macro is now deprecated in favour of this\r
* xSemaphoreCreateBinary() function. Note that binary semaphores created using\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xSemaphore = NULL;\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
\r
void vATask( void * pvParameters )\r
{\r
* \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary\r
* \ingroup Semaphores\r
*/\r
-#define xSemaphoreCreateBinary() xQueueGenericCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
+#define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
\r
/**\r
* semphr. h\r
* <pre>xSemaphoreTake(\r
- * xSemaphoreHandle xSemaphore,\r
- * portTickType xBlockTime\r
+ * SemaphoreHandle_t xSemaphore,\r
+ * TickType_t xBlockTime\r
* )</pre>\r
*\r
* <i>Macro</i> to obtain a semaphore. The semaphore must have previously been\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xSemaphore = NULL;\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
\r
// A task that creates a semaphore.\r
void vATask( void * pvParameters )\r
{\r
// See if we can obtain the semaphore. If the semaphore is not available\r
// wait 10 ticks to see if it becomes free.\r
- if( xSemaphoreTake( xSemaphore, ( portTickType ) 10 ) == pdTRUE )\r
+ if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )\r
{\r
// We were able to obtain the semaphore and can now access the\r
// shared resource.\r
* \defgroup xSemaphoreTake xSemaphoreTake\r
* \ingroup Semaphores\r
*/\r
-#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )\r
+#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )\r
\r
/**\r
* semphr. h\r
* xSemaphoreTakeRecursive(\r
- * xSemaphoreHandle xMutex,\r
- * portTickType xBlockTime\r
+ * SemaphoreHandle_t xMutex,\r
+ * TickType_t xBlockTime\r
* )\r
*\r
* <i>Macro</i> to recursively obtain, or 'take', a mutex type semaphore.\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xMutex = NULL;\r
+ SemaphoreHandle_t xMutex = NULL;\r
\r
// A task that creates a mutex.\r
void vATask( void * pvParameters )\r
{\r
// See if we can obtain the mutex. If the mutex is not available\r
// wait 10 ticks to see if it becomes free.\r
- if( xSemaphoreTakeRecursive( xSemaphore, ( portTickType ) 10 ) == pdTRUE )\r
+ if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )\r
{\r
// We were able to obtain the mutex and can now access the\r
// shared resource.\r
// code these would not be just sequential calls as this would make\r
// no sense. Instead the calls are likely to be buried inside\r
// a more complex call structure.\r
- xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 );\r
- xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 );\r
+ xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );\r
+ xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );\r
\r
// The mutex has now been 'taken' three times, so will not be\r
// available to another task until it has also been given back\r
* responsiveness to gain execution speed, whereas the fully featured API\r
* sacrifices execution speed to ensure better interrupt responsiveness.\r
*/\r
-#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )\r
+#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )\r
\r
/**\r
* semphr. h\r
- * <pre>xSemaphoreGive( xSemaphoreHandle xSemaphore )</pre>\r
+ * <pre>xSemaphoreGive( SemaphoreHandle_t xSemaphore )</pre>\r
*\r
* <i>Macro</i> to release a semaphore. The semaphore must have previously been\r
* created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xSemaphore = NULL;\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
\r
void vATask( void * pvParameters )\r
{\r
\r
// Obtain the semaphore - don't block if the semaphore is not\r
// immediately available.\r
- if( xSemaphoreTake( xSemaphore, ( portTickType ) 0 ) )\r
+ if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )\r
{\r
// We now have the semaphore and can access the shared resource.\r
\r
* \defgroup xSemaphoreGive xSemaphoreGive\r
* \ingroup Semaphores\r
*/\r
-#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )\r
+#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )\r
\r
/**\r
* semphr. h\r
- * <pre>xSemaphoreGiveRecursive( xSemaphoreHandle xMutex )</pre>\r
+ * <pre>xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )</pre>\r
*\r
* <i>Macro</i> to recursively release, or 'give', a mutex type semaphore.\r
* The mutex must have previously been created using a call to\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xMutex = NULL;\r
+ SemaphoreHandle_t xMutex = NULL;\r
\r
// A task that creates a mutex.\r
void vATask( void * pvParameters )\r
{\r
// See if we can obtain the mutex. If the mutex is not available\r
// wait 10 ticks to see if it becomes free.\r
- if( xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 ) == pdTRUE )\r
+ if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )\r
{\r
// We were able to obtain the mutex and can now access the\r
// shared resource.\r
// code these would not be just sequential calls as this would make\r
// no sense. Instead the calls are likely to be buried inside\r
// a more complex call structure.\r
- xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 );\r
- xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 );\r
+ xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );\r
+ xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );\r
\r
// The mutex has now been 'taken' three times, so will not be\r
// available to another task until it has also been given back\r
* responsiveness to gain execution speed, whereas the fully featured API\r
* sacrifices execution speed to ensure better interrupt responsiveness.\r
*/\r
-#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )\r
+#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )\r
\r
/**\r
* semphr. h\r
* <pre>\r
xSemaphoreGiveFromISR(\r
- xSemaphoreHandle xSemaphore,\r
- signed portBASE_TYPE *pxHigherPriorityTaskWoken\r
+ SemaphoreHandle_t xSemaphore,\r
+ BaseType_t *pxHigherPriorityTaskWoken\r
)</pre>\r
*\r
* <i>Macro</i> to release a semaphore. The semaphore must have previously been\r
<pre>\r
\#define LONG_TIME 0xffff\r
\#define TICKS_TO_WAIT 10\r
- xSemaphoreHandle xSemaphore = NULL;\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
\r
// Repetitive task.\r
void vATask( void * pvParameters )\r
// Timer ISR\r
void vTimerISR( void * pvParameters )\r
{\r
- static unsigned char ucLocalTickCount = 0;\r
- static signed portBASE_TYPE xHigherPriorityTaskWoken;\r
+ static uint8_t ucLocalTickCount = 0;\r
+ static BaseType_t xHigherPriorityTaskWoken;\r
\r
// A timer tick has occurred.\r
\r
* \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR\r
* \ingroup Semaphores\r
*/\r
-#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )\r
+#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )\r
\r
/**\r
* semphr. h\r
* <pre>\r
xSemaphoreTakeFromISR(\r
- xSemaphoreHandle xSemaphore,\r
- signed portBASE_TYPE *pxHigherPriorityTaskWoken\r
+ SemaphoreHandle_t xSemaphore,\r
+ BaseType_t *pxHigherPriorityTaskWoken\r
)</pre>\r
*\r
* <i>Macro</i> to take a semaphore from an ISR. The semaphore must have\r
* @return pdTRUE if the semaphore was successfully taken, otherwise\r
* pdFALSE\r
*/\r
-#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )\r
+#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )\r
\r
/**\r
* semphr. h\r
- * <pre>xSemaphoreHandle xSemaphoreCreateMutex( void )</pre>\r
+ * <pre>SemaphoreHandle_t xSemaphoreCreateMutex( void )</pre>\r
*\r
* <i>Macro</i> that implements a mutex semaphore by using the existing queue\r
* mechanism.\r
* service routines.\r
*\r
* @return xSemaphore Handle to the created mutex semaphore. Should be of type\r
- * xSemaphoreHandle.\r
+ * SemaphoreHandle_t.\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xSemaphore;\r
+ SemaphoreHandle_t xSemaphore;\r
\r
void vATask( void * pvParameters )\r
{\r
\r
/**\r
* semphr. h\r
- * <pre>xSemaphoreHandle xSemaphoreCreateRecursiveMutex( void )</pre>\r
+ * <pre>SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )</pre>\r
*\r
* <i>Macro</i> that implements a recursive mutex by using the existing queue\r
* mechanism.\r
* service routines.\r
*\r
* @return xSemaphore Handle to the created mutex semaphore. Should be of type\r
- * xSemaphoreHandle.\r
+ * SemaphoreHandle_t.\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xSemaphore;\r
+ SemaphoreHandle_t xSemaphore;\r
\r
void vATask( void * pvParameters )\r
{\r
\r
/**\r
* semphr. h\r
- * <pre>xSemaphoreHandle xSemaphoreCreateCounting( unsigned portBASE_TYPE uxMaxCount, unsigned portBASE_TYPE uxInitialCount )</pre>\r
+ * <pre>SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount )</pre>\r
*\r
* <i>Macro</i> that creates a counting semaphore by using the existing\r
* queue mechanism.\r
*\r
* Example usage:\r
<pre>\r
- xSemaphoreHandle xSemaphore;\r
+ SemaphoreHandle_t xSemaphore;\r
\r
void vATask( void * pvParameters )\r
{\r
- xSemaphoreHandle xSemaphore = NULL;\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
\r
// Semaphore cannot be used before a call to xSemaphoreCreateCounting().\r
// The max value to which the semaphore can count should be 10, and the\r
\r
/**\r
* semphr. h\r
- * <pre>void vSemaphoreDelete( xSemaphoreHandle xSemaphore );</pre>\r
+ * <pre>void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );</pre>\r
*\r
* Delete a semaphore. This function must be used with care. For example,\r
* do not delete a mutex type semaphore if the mutex is held by a task.\r
* \defgroup vSemaphoreDelete vSemaphoreDelete\r
* \ingroup Semaphores\r
*/\r
-#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( xQueueHandle ) ( xSemaphore ) )\r
+#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) )\r
\r
/**\r
* semphr.h\r
- * <pre>xTaskHandle xSemaphoreGetMutexHolder( xSemaphoreHandle xMutex );</pre>\r
+ * <pre>TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );</pre>\r
*\r
* If xMutex is indeed a mutex type semaphore, return the current mutex holder.\r
* If xMutex is not a mutex type semaphore, or the mutex is available (not held\r
* by a task), return NULL.\r
*\r
- * Note: This Is is a good way of determining if the calling task is the mutex\r
+ * Note: This is a good way of determining if the calling task is the mutex\r
* holder, but not a good way of determining the identity of the mutex holder as\r
* the holder may change between the function exiting and the returned value\r
* being tested.\r