blob: ffdf92c36d23dcf732c251a1bb834bc57e5cedc2 [file] [log] [blame]
BohdanHunkof871df02023-02-03 14:36:41 +02001/*
2 * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
3 * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company)
4 * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 *
8 */
9
10#ifndef __OS_WRAPPER_MUTEX_H__
11#define __OS_WRAPPER_MUTEX_H__
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#include "os_wrapper/common.h"
18
19/**
20 * \brief Creates a mutex for mutual exclusion of resources
21 *
22 * \return The handle of the created mutex on success or NULL on error
23 */
24void *os_wrapper_mutex_create(void);
25
26/**
27 * \brief Acquires a mutex that is created by \ref os_wrapper_mutex_create()
28 *
29 * \param[in] handle The handle of the mutex to acquire. Should be one of the
30 * handles returned by \ref os_wrapper_mutex_create()
31 * \param[in] timeout The maximum amount of time(in tick periods) for the
32 * thread to wait for the mutex to be available.
33 * If timeout is zero, the function will return immediately.
34 * Setting timeout to \ref OS_WRAPPER_WAIT_FOREVER will
35 * cause the thread to wait indefinitely
36 *
37 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
38 * or timeout
39 */
40uint32_t os_wrapper_mutex_acquire(void *handle, uint32_t timeout);
41
42/**
43 * \brief Releases the mutex acquired previously
44 *
45
46 * \param[in] handle The handle of the mutex that has been acquired
47 *
48 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
49 */
50uint32_t os_wrapper_mutex_release(void *handle);
51
52/**
53 * \brief Deletes a mutex that is created by \ref os_wrapper_mutex_create()
54 *
55 * \param[in] handle The handle of the mutex to be deleted
56 *
57 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
58 */
59uint32_t os_wrapper_mutex_delete(void *handle);
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif /* __OS_WRAPPER_MUTEX_H__ */