David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017-2020, Arm Limited. All rights reserved. |
BohdanHunko | 75ee82b | 2023-02-03 14:47:01 +0200 | [diff] [blame] | 3 | * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company) |
| 4 | * or an affiliate of Cypress Semiconductor Corporation. All rights reserved. |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 5 | * |
| 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 |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
BohdanHunko | 75ee82b | 2023-02-03 14:47:01 +0200 | [diff] [blame] | 17 | #include "os_wrapper/common.h" |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 18 | |
| 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 | */ |
| 28 | void *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 | */ |
| 40 | uint32_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 | */ |
| 50 | uint32_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 | */ |
| 60 | uint32_t os_wrapper_semaphore_delete(void *handle); |
| 61 | |
| 62 | #ifdef __cplusplus |
| 63 | } |
| 64 | #endif |
| 65 | |
| 66 | #endif /* __OS_WRAPPER_SEMAPHORE_H__ */ |