summaryrefslogtreecommitdiff
path: root/nrfdemo/builddk/tfm/api_ns/interface/include/os_wrapper/mutex.h
blob: ffdf92c36d23dcf732c251a1bb834bc57e5cedc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
 * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company)
 * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

#ifndef __OS_WRAPPER_MUTEX_H__
#define __OS_WRAPPER_MUTEX_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "os_wrapper/common.h"

/**
 * \brief Creates a mutex for mutual exclusion of resources
 *
 * \return The handle of the created mutex on success or NULL on error
 */
void *os_wrapper_mutex_create(void);

/**
 * \brief Acquires a mutex that is created by \ref os_wrapper_mutex_create()
 *
 * \param[in] handle   The handle of the mutex to acquire. Should be one of the
 *                     handles returned by \ref os_wrapper_mutex_create()
 * \param[in] timeout  The maximum amount of time(in tick periods) for the
 *                     thread to wait for the mutex to be available.
 *                     If timeout is zero, the function will return immediately.
 *                     Setting timeout to \ref OS_WRAPPER_WAIT_FOREVER will
 *                     cause the thread to wait indefinitely
 *
 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
 *              or timeout
 */
uint32_t os_wrapper_mutex_acquire(void *handle, uint32_t timeout);

/**
 * \brief Releases the mutex acquired previously
 *

 * \param[in] handle The handle of the mutex that has been acquired
 *
 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
 */
uint32_t os_wrapper_mutex_release(void *handle);

/**
 * \brief Deletes a mutex that is created by \ref os_wrapper_mutex_create()
 *
 * \param[in] handle The handle of the mutex to be deleted
 *
 * \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error
 */
uint32_t os_wrapper_mutex_delete(void *handle);

#ifdef __cplusplus
}
#endif

#endif /* __OS_WRAPPER_MUTEX_H__ */