1 /******************************************************************************
2  *
3  *  Copyright (C) 2015 Google, Inc.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #ifndef __SEMAPHORE_H__
20 #define __SEMAPHORE_H__
21 
22 #include "freertos/FreeRTOS.h"
23 #include "freertos/task.h"
24 #include "freertos/queue.h"
25 #include "freertos/semphr.h"
26 
27 #define OSI_SEM_MAX_TIMEOUT 0xffffffffUL
28 
29 typedef xSemaphoreHandle osi_sem_t;
30 
31 #define osi_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
32 #define osi_sem_set_invalid( x ) ( ( *x ) = NULL )
33 
34 int osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count);
35 
36 void osi_sem_free(osi_sem_t *sem);
37 
38 int osi_sem_take(osi_sem_t *sem, uint32_t timeout);
39 
40 void osi_sem_give(osi_sem_t *sem);
41 
42 
43 #endif /* __SEMAPHORE_H__ */
44