1 /*
2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #ifndef BSP_SEMAPHORE_H
8 #define BSP_SEMAPHORE_H
9
10 /** Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
11 FSP_HEADER
12
13 /***********************************************************************************************************************
14 * Macro definitions
15 **********************************************************************************************************************/
16
17 /***********************************************************************************************************************
18 * Typedef definitions
19 **********************************************************************************************************************/
20
21 /*******************************************************************************************************************//**
22 * @addtogroup BSP_MCU
23 * @{
24 **********************************************************************************************************************/
25
26 /** The semaphore resource state shared by CPU0 and CPU1 */
27 typedef enum e_bsp_resource_state
28 {
29 BSP_RESOURCE_STATE_BEING_USED = 0, ///< Semaphore resource being used.
30 BSP_RESOURCE_STATE_NOT_BEING_USED = 1, ///< Semaphore resource not being used.
31 } bsp_resource_state_t;
32
33 /** The semaphore resource number shared by CPU0 and CPU1 */
34 typedef enum e_bsp_resource_num
35 {
36 BSP_RESOURCE_NUM_0 = 0, ///< Semaphore resource number 0
37 BSP_RESOURCE_NUM_1 = 1, ///< Semaphore resource number 1
38 BSP_RESOURCE_NUM_2 = 2, ///< Semaphore resource number 2
39 BSP_RESOURCE_NUM_3 = 3, ///< Semaphore resource number 3
40 BSP_RESOURCE_NUM_4 = 4, ///< Semaphore resource number 4
41 BSP_RESOURCE_NUM_5 = 5, ///< Semaphore resource number 5
42 BSP_RESOURCE_NUM_6 = 6, ///< Semaphore resource number 6
43 BSP_RESOURCE_NUM_7 = 7, ///< Semaphore resource number 7
44 } bsp_resource_num_t;
45
46 /** @} (end addtogroup BSP_MCU) */
47
48 #if BSP_FEATURE_BSP_SEMAPHORE_SUPPORTED
49
50 /***********************************************************************************************************************
51 * Exported global variables
52 **********************************************************************************************************************/
53
54 /***********************************************************************************************************************
55 * Exported global functions (to be accessed by other files)
56 **********************************************************************************************************************/
57
58 /*******************************************************************************************************************//**
59 * Read semaphore resource status. When SYTSEMFEN = 1, reading this status clear the resource status.
60 *
61 * @param[in] sem_num Semaphore number to read resource status.
62 *
63 * @retval Resource status.
64 **********************************************************************************************************************/
R_BSP_SemaphoreStateRead(bsp_resource_num_t sem_num)65 __STATIC_INLINE uint32_t R_BSP_SemaphoreStateRead (bsp_resource_num_t sem_num)
66 {
67 #if BSP_FEATURE_SEM_SUPPORTED
68 uint32_t sem = R_SEM->SYTSEMF[sem_num];
69 #elif BSP_FEATURE_MAILBOX_SEM_SUPPORTED
70 uint32_t sem = R_MBXSEM->SEM[sem_num];
71 #else
72 uint32_t sem = 0;
73 #endif
74
75 return sem;
76 }
77
78 #endif
79
80 /* Public functions defined in bsp.h */
81 void bsp_semaphore_init(void); // Used internally by BSP
82
83 /** Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
84 FSP_FOOTER
85
86 #endif
87