David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020-2021, 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_MSG_QUEUE_H__ |
| 11 | #define __OS_WRAPPER_MSG_QUEUE_H__ |
| 12 | |
| 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | #include <stddef.h> |
| 18 | |
BohdanHunko | 75ee82b | 2023-02-03 14:47:01 +0200 | [diff] [blame] | 19 | #include "os_wrapper/common.h" |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * \brief Create and initialize a message queue |
| 23 | * |
| 24 | * \param[in] msg_size The maximum message size in bytes |
| 25 | * \param[in] msg_count The maximum number of messages in queue |
| 26 | * |
| 27 | * \return Returns handle of the message queue created, or NULL in case of error |
| 28 | */ |
| 29 | void *os_wrapper_msg_queue_create(size_t msg_size, uint8_t msg_count); |
| 30 | |
| 31 | /** |
| 32 | * \brief Send a message via message queue |
| 33 | * |
| 34 | * \param[in] mq_handle The handle of message queue |
| 35 | * \param[in] msg_ptr The pointer to the message to be sent |
| 36 | * |
| 37 | * \return \ref OS_WRAPPER_SUCCESS if the message is successfully sent, or |
| 38 | * \ref OS_WRAPPER_ERROR in case of error |
| 39 | * |
| 40 | * \note The message size must be the same as the value set in |
| 41 | * \ref os_wrapper_msg_queue_create. |
| 42 | * |
| 43 | * \note Time out value is not specified here. Whether the function is blocked |
| 44 | * or returns instantly depends on the actual implementation and usage |
| 45 | * scenario. |
| 46 | */ |
| 47 | int32_t os_wrapper_msg_queue_send(void *mq_handle, |
| 48 | const void *msg_ptr); |
| 49 | |
| 50 | /** |
| 51 | * \brief Receive a message from message queue |
| 52 | * |
| 53 | * \param[in] mq_handle The handle of message queue |
| 54 | * \param[in] msg_ptr The pointer to buffer for message to be received |
| 55 | * |
| 56 | * \return \ref OS_WRAPPER_SUCCESS if the message is successfully received, or |
| 57 | * \ref OS_WRAPPER_ERROR in case of error |
| 58 | * |
| 59 | * \note The message size is the same as the value set in |
| 60 | * \ref os_wrapper_msg_queue_create. |
| 61 | * |
| 62 | * \note The function should be blocked until a message is received from message |
| 63 | * queue, unless an error occurs. |
| 64 | */ |
| 65 | int32_t os_wrapper_msg_queue_receive(void *mq_handle, |
| 66 | void *msg_ptr); |
| 67 | |
| 68 | #ifdef __cplusplus |
| 69 | } |
| 70 | #endif |
| 71 | |
| 72 | #endif /* __OS_WRAPPER_MSG_QUEUE_H__ */ |