ZestCode
 
Loading...
Searching...
No Matches
semphr.h
1/*
2 * FreeRTOS Kernel V10.0.1
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * http://www.FreeRTOS.org
23 * http://aws.amazon.com/freertos
24 *
25 * 1 tab == 4 spaces!
26 */
27
28#ifndef SEMAPHORE_H
29#define SEMAPHORE_H
30
31#ifndef INC_FREERTOS_H
32 #error "include FreeRTOS.h" must appear in source files before "include semphr.h"
33#endif
34
35#include "queue.h"
36#include "task.h"
37
38typedef queue_t sem_t;
39typedef queue_t mutex_t;
40
41#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U )
42#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U )
43#define semGIVE_BLOCK_TIME ( ( uint32_t ) 0U )
44
45
95#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
96 #define vSemaphoreCreateBinary( xSemaphore ) \
97 { \
98 ( xSemaphore ) = xQueueGenericCreate( ( uint32_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \
99 if( ( xSemaphore ) != NULL ) \
100 { \
101 ( void ) sem_post( ( xSemaphore ) ); \
102 } \
103 }
104#endif
105
163#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
164 sem_t sem_binary_create();
165#endif
166
222#if( configSUPPORT_STATIC_ALLOCATION == 1 )
223 #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( uint32_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE )
224#endif /* configSUPPORT_STATIC_ALLOCATION */
225
291uint8_t sem_wait(sem_t sem, uint32_t block_time);
292
384#if( configUSE_RECURSIVE_MUTEXES == 1 )
385 uint8_t mutex_recursive_take(mutex_t mutex, uint32_t block_time);
386#endif
387
449uint8_t sem_post(sem_t sem);
450
533#if( configUSE_RECURSIVE_MUTEXES == 1 )
534 uint8_t mutex_recursive_give(mutex_t mutex);
535#endif
536
626#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( queue_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) )
627
660#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( queue_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )
661
717#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
719#endif
720
778 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
779 mutex_t mutex_create_static(static_sem_s_t* pxMutexBuffer);
780#endif /* configSUPPORT_STATIC_ALLOCATION */
781
782
846#if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) )
848#endif
849
919#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) )
920 #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore )
921#endif /* configSUPPORT_STATIC_ALLOCATION */
922
999#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
1000 sem_t sem_create(uint32_t uxMaxCount, uint32_t uxInitialCount);
1001#endif
1002
1084#if( configSUPPORT_STATIC_ALLOCATION == 1 )
1085 sem_t sem_create_static(uint32_t uxMaxCount, uint32_t uxInitialCount, static_sem_s_t* pxSemaphoreBuffer);
1086#endif /* configSUPPORT_STATIC_ALLOCATION */
1087
1100void sem_delete(sem_t xSemaphore);
1101
1115task_t mutex_get_owner(sem_t xMutex);
1116
1126#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) )
1127
1138uint32_t sem_get_count(sem_t xSemaphore);
1139
1140#endif /* SEMAPHORE_H */
1141
1142
void sem_delete(sem_t sem)
task_t mutex_get_owner(mutex_t mutex)
sem_t sem_create(uint32_t max_count, uint32_t init_count)
uint32_t sem_get_count(sem_t sem)
sem_t sem_binary_create(void)
bool sem_post(sem_t sem)
bool sem_wait(sem_t sem, uint32_t timeout)
void * task_t
Definition rtos.h:100
mutex_t mutex_create(void)
bool mutex_recursive_take(mutex_t mutex, uint32_t timeout)
bool mutex_recursive_give(mutex_t mutex)
void * mutex_t
Definition rtos.h:184
mutex_t mutex_recursive_create(void)
sem_t sem_create_static(uint32_t max_count, uint32_t init_count, static_sem_s_t *semaphore_buffer)
mutex_t mutex_create_static(static_sem_s_t *mutex_buffer)