Microchip® Advanced Software Framework

freertos-7.4.2/Source/include/semphr.h File Reference
#include "queue.h"

Macros

#define semBINARY_SEMAPHORE_QUEUE_LENGTH   ( ( unsigned char ) 1U )
 
#define semGIVE_BLOCK_TIME   ( ( portTickType ) 0U )
 
#define semSEMAPHORE_QUEUE_ITEM_LENGTH   ( ( unsigned char ) 0U )
 
#define vSemaphoreCreateBinary(xSemaphore)
 
#define vSemaphoreDelete(xSemaphore)   vQueueDelete( ( xQueueHandle ) ( xSemaphore ) )
 
#define xSemaphoreAltGive(xSemaphore)   xQueueAltGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
 
#define xSemaphoreAltTake(xSemaphore, xBlockTime)   xQueueAltGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )
 
#define xSemaphoreCreateCounting(uxMaxCount, uxInitialCount)   xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) )
 
#define xSemaphoreCreateMutex()   xQueueCreateMutex( queueQUEUE_TYPE_MUTEX )
 
#define xSemaphoreCreateRecursiveMutex()   xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX )
 
#define xSemaphoreGetMutexHolder(xSemaphore)   xQueueGetMutexHolder( ( xSemaphore ) )
 semphr.h More...
 
#define xSemaphoreGive(xSemaphore)   xQueueGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
 
#define xSemaphoreGiveFromISR(xSemaphore, pxHigherPriorityTaskWoken)   xQueueGenericSendFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
 
#define xSemaphoreGiveRecursive(xMutex)   xQueueGiveMutexRecursive( ( xMutex ) )
 
#define xSemaphoreTake(xSemaphore, xBlockTime)   xQueueGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )
 
#define xSemaphoreTakeFromISR(xSemaphore, pxHigherPriorityTaskWoken)   xQueueReceiveFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )
 semphr. More...
 
#define xSemaphoreTakeRecursive(xMutex, xBlockTime)   xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) )
 

Typedefs

typedef xQueueHandle xSemaphoreHandle
 

#define semBINARY_SEMAPHORE_QUEUE_LENGTH   ( ( unsigned char ) 1U )
#define semGIVE_BLOCK_TIME   ( ( portTickType ) 0U )
#define semSEMAPHORE_QUEUE_ITEM_LENGTH   ( ( unsigned char ) 0U )
#define vSemaphoreCreateBinary (   xSemaphore)
Value:
{ \
( xSemaphore ) = xQueueGenericCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \
if( ( xSemaphore ) != NULL ) \
{ \
xSemaphoreGive( ( xSemaphore ) ); \
} \
}
#define queueQUEUE_TYPE_BINARY_SEMAPHORE
Definition: freertos-7.5.2/Source/include/queue.h:109
#define NULL
Definition: def.h:47
#define xSemaphoreGive(xSemaphore)
Definition: freertos-7.4.2/Source/include/semphr.h:374
if(memp!=NULL)
Definition: memp.c:407
#define semSEMAPHORE_QUEUE_ITEM_LENGTH
Definition: freertos-7.4.2/Source/include/semphr.h:87
xQueueHandle xQueueGenericCreate(unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType)
Definition: freertos-7.5.2/Source/queue.c:283
#define vSemaphoreDelete (   xSemaphore)    vQueueDelete( ( xQueueHandle ) ( xSemaphore ) )
#define xSemaphoreAltGive (   xSemaphore)    xQueueAltGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
#define xSemaphoreAltTake (   xSemaphore,
  xBlockTime 
)    xQueueAltGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )
#define xSemaphoreCreateCounting (   uxMaxCount,
  uxInitialCount 
)    xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) )
#define xSemaphoreCreateMutex ( )    xQueueCreateMutex( queueQUEUE_TYPE_MUTEX )
#define xSemaphoreCreateRecursiveMutex ( )    xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX )
#define xSemaphoreGetMutexHolder (   xSemaphore)    xQueueGetMutexHolder( ( xSemaphore ) )

semphr.h

xTaskHandle xSemaphoreGetMutexHolder( xSemaphoreHandle xMutex );

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.

Note: This Is is a good way of determining if the calling task is the mutex holder, but not a good way of determining the identity of the mutex holder as the holder may change between the function exiting and the returned value being tested.

#define xSemaphoreGive (   xSemaphore)    xQueueGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
#define xSemaphoreGiveFromISR (   xSemaphore,
  pxHigherPriorityTaskWoken 
)    xQueueGenericSendFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
#define xSemaphoreGiveRecursive (   xMutex)    xQueueGiveMutexRecursive( ( xMutex ) )
#define xSemaphoreTake (   xSemaphore,
  xBlockTime 
)    xQueueGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )
#define xSemaphoreTakeFromISR (   xSemaphore,
  pxHigherPriorityTaskWoken 
)    xQueueReceiveFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )

semphr.

h

xSemaphoreTakeFromISR( 
                         xSemaphoreHandle xSemaphore, 
                         signed portBASE_TYPE *pxHigherPriorityTaskWoken
                     )

Macro to take a semaphore from an ISR. The semaphore must have previously been created with a call to vSemaphoreCreateBinary() or xSemaphoreCreateCounting().

Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) must not be used with this macro.

This macro can be used from an ISR, however taking a semaphore from an ISR is not a common operation. It is likely to only be useful when taking a counting semaphore when an interrupt is obtaining an object from a resource pool (when the semaphore count indicates the number of resources available).

Parameters
xSemaphoreA handle to the semaphore being taken. This is the handle returned when the semaphore was created.
pxHigherPriorityTaskWokenxSemaphoreTakeFromISR() 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 a context switch should be requested before the interrupt is exited.
Returns
pdTRUE if the semaphore was successfully taken, otherwise pdFALSE
#define xSemaphoreTakeRecursive (   xMutex,
  xBlockTime 
)    xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) )