11#ifndef FREERTOS_SEMPHR_H
12#define FREERTOS_SEMPHR_H
16#include "freertos/FreeRTOS.h"
17#include "freertos/task.h"
26typedef void* SemaphoreHandle_t;
28SemaphoreHandle_t xSemaphoreCreateMutex(
void);
29SemaphoreHandle_t xSemaphoreCreateRecursiveMutex(
void);
31void vSemaphoreDelete (SemaphoreHandle_t xSemaphore);
33BaseType_t xSemaphoreGive (SemaphoreHandle_t xSemaphore);
34BaseType_t xSemaphoreTake (SemaphoreHandle_t xSemaphore,
35 TickType_t xTicksToWait);
36BaseType_t xSemaphoreGiveRecursive (SemaphoreHandle_t xSemaphore);
37BaseType_t xSemaphoreTakeRecursive (SemaphoreHandle_t xSemaphore,
38 TickType_t xTicksToWait);
40TaskHandle_t xSemaphoreGetMutexHolder(SemaphoreHandle_t xMutex);
42#define vPortCPUInitializeMutex(m) mutex_init(m)
44void vPortCPUAcquireMutex (portMUX_TYPE *mux);
45void vPortCPUReleaseMutex (portMUX_TYPE *mux);
62#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U )
64#define xSemaphoreCreateBinary() \
65 xQueueGenericCreate( ( UBaseType_t ) 1, \
66 semSEMAPHORE_QUEUE_ITEM_LENGTH, \
67 queueQUEUE_TYPE_BINARY_SEMAPHORE )
68#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) \
69 xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) )
71#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) \
72 xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), \
73 NULL, ( pxHigherPriorityTaskWoken ) )
75#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) \
76 xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), \
77 ( pxHigherPriorityTaskWoken ) )
Mutex for thread synchronization.