Loading...
Searching...
No Matches
semphr.h
1/*
2 * Copyright (C) 2019 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 *
8 * FreeRTOS to RIOT-OS adaption module for source code compatibility
9 */
10
11#ifndef FREERTOS_SEMPHR_H
12#define FREERTOS_SEMPHR_H
13
14#ifndef DOXYGEN
15
16#include "freertos/FreeRTOS.h"
17#include "freertos/task.h"
18
19#include <stdlib.h>
20#include "mutex.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26typedef void* SemaphoreHandle_t;
27
28SemaphoreHandle_t xSemaphoreCreateMutex(void);
29SemaphoreHandle_t xSemaphoreCreateRecursiveMutex(void);
30
31void vSemaphoreDelete (SemaphoreHandle_t xSemaphore);
32
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);
39
40TaskHandle_t xSemaphoreGetMutexHolder(SemaphoreHandle_t xMutex);
41
42#define vPortCPUInitializeMutex(m) mutex_init(m)
43
44void vPortCPUAcquireMutex (portMUX_TYPE *mux);
45void vPortCPUReleaseMutex (portMUX_TYPE *mux);
46
47/*
48 * PLEASE NOTE: Following definitions were copied directly from the FreeRTOS
49 * distribution and are under the following copyright:
50 *
51 * FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd.
52 * All rights reserved
53 *
54 * FreeRTOS is free software; you can redistribute it and/or modify it under
55 * the terms of the GNU General Public License (version 2) as published by the
56 * Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
57 *
58 * Full license text is available on the following
59 * link: http://www.freertos.org/a00114.html
60 */
61
62#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U )
63
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 ) )
70
71#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) \
72 xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), \
73 NULL, ( pxHigherPriorityTaskWoken ) )
74
75#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) \
76 xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), \
77 ( pxHigherPriorityTaskWoken ) )
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* DOXYGEN */
84#endif /* FREERTOS_SEMPHR_H */
Mutex for thread synchronization.