Loading...
Searching...
No Matches
dpl_sem.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Inria
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
9#pragma once
10
21
22#include <stdint.h>
23
24#include "dpl_types.h"
25#include "dpl_error.h"
26#include "os/os_sem.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
35struct dpl_sem {
36 struct os_sem sem;
37};
38
49static inline dpl_error_t dpl_sem_init(struct dpl_sem *sem, uint16_t tokens)
50{
51 return (dpl_error_t) os_sem_init(&sem->sem, tokens);
52}
53
68static inline dpl_error_t dpl_sem_pend(struct dpl_sem *sem, dpl_time_t timeout)
69{
70 return (dpl_error_t) os_sem_pend(&sem->sem, timeout);
71}
72
82static inline dpl_error_t dpl_sem_release(struct dpl_sem *sem)
83{
84 return (dpl_error_t) os_sem_release(&sem->sem);
85}
86
90static inline int16_t dpl_sem_get_count(struct dpl_sem *sem)
91{
92 return os_sem_get_count(&sem->sem);
93}
94
95#ifdef __cplusplus
96}
97#endif
uwb-core DPL (Decawave Porting Layer) error types
os_error_t dpl_error_t
dpl error type
Definition dpl_error.h:50
static dpl_error_t dpl_sem_release(struct dpl_sem *sem)
Release a semaphore.
Definition dpl_sem.h:82
static dpl_error_t dpl_sem_pend(struct dpl_sem *sem, dpl_time_t timeout)
Pend (wait) for a semaphore.
Definition dpl_sem.h:68
static dpl_error_t dpl_sem_init(struct dpl_sem *sem, uint16_t tokens)
Initialize a semaphore.
Definition dpl_sem.h:49
static int16_t dpl_sem_get_count(struct dpl_sem *sem)
Get current semaphore's count.
Definition dpl_sem.h:90
uwb-core DPL (Decawave Porting Layer) types
os_time_t dpl_time_t
dpl time type
Definition dpl_types.h:56
dpl semaphore wrapper
Definition dpl_sem.h:35
struct os_sem sem
the semaphore
Definition dpl_sem.h:36