blob: ce5aa049b86f50052198de6e33b8c0bd0c663543 [file] [log] [blame]
David Hucdc51fb2021-04-06 18:10:46 +08001/*
2 * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
BohdanHunko75ee82b2023-02-03 14:47:01 +02003 * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company)
4 * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
David Hucdc51fb2021-04-06 18:10:46 +08005 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 *
8 */
9
10#ifndef __OS_WRAPPER_SEMAPHORE_H__
11#define __OS_WRAPPER_SEMAPHORE_H__
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
BohdanHunko75ee82b2023-02-03 14:47:01 +020017#include "os_wrapper/common.h"
David Hucdc51fb2021-04-06 18:10:46 +080018
19/**
20 * \brief Creates a new semaphore
21 *
22 * \param[in] max_count Highest count of the semaphore
23 * \param[in] initial_count Starting count of the available semaphore
24 * \param[in] name Name of the semaphore
25 *
26 * \return Returns handle of the semaphore created, or NULL in case of error
27 */
28void *os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count,
29 const char *name);
30
31/**
32 * \brief Acquires the semaphore
33 *
34 * \param[in] hanlde Semaphore handle
35 * \param[in] timeout Timeout value
36 *
37 * \return \ref OS_WRAPPER_SUCCESS in case of successful acquision, or
38 * \ref OS_WRAPPER_ERROR in case of error
39 */
40uint32_t os_wrapper_semaphore_acquire(void *handle, uint32_t timeout);
41
42/**
43 * \brief Releases the semaphore
44 *
45 * \param[in] hanlde Semaphore handle
46 *
47 * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
48 * \ref OS_WRAPPER_ERROR in case of error
49 */
50uint32_t os_wrapper_semaphore_release(void *handle);
51
52/**
53 * \brief Deletes the semaphore
54 *
55 * \param[in] handle Semaphore handle
56 *
57 * \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
58 * \ref OS_WRAPPER_ERROR in case of error
59 */
60uint32_t os_wrapper_semaphore_delete(void *handle);
61
62#ifdef __cplusplus
63}
64#endif
65
66#endif /* __OS_WRAPPER_SEMAPHORE_H__ */