1 /*
2  * Copyright 2021-2024 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 #ifndef MRU_IP_TRUSTEDFUNCTIONS_H
7 #define MRU_IP_TRUSTEDFUNCTIONS_H
8 
9 /**
10 *   @file Mru_Ip_TrustedFunctions.h
11 *
12 *   @addtogroup MRU_IP_DRIVER Mru Ip Driver
13 *   @{
14 */
15 
16 /*==================================================================================================
17 *                                        INCLUDE FILES
18 ==================================================================================================*/
19 #include "Mru_Ip_Types.h"
20 
21 /*==================================================================================================
22 *                              SOURCE FILE VERSION INFORMATION
23 ==================================================================================================*/
24 #define CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_VENDOR_ID                      43
25 #define CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MAJOR_VERSION       4
26 #define CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MINOR_VERSION       7
27 #define CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_AR_RELEASE_REVISION_VERSION    0
28 #define CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_SW_MAJOR_VERSION               2
29 #define CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_SW_MINOR_VERSION               0
30 #define CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_SW_PATCH_VERSION               0
31 
32 /*==================================================================================================
33 *                                     FILE VERSION CHECKS
34 ==================================================================================================*/
35 /* Check if Mpu_R52_Ip_TrustedFunctions.h and Mpu_R52_Ip_Cfg.h are of the same vendor */
36 #if (CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_VENDOR_ID != CDD_PLATFORM_MRU_IP_TYPES_VENDOR_ID)
37     #error "Mpu_R52_Ip_TrustedFunctions.h and Mru_Ip_Types.h have different vendor ids"
38 #endif
39 /* Check if Mpu_R52_Ip_TrustedFunctions.h file and Mpu_R52_Ip_Cfg.h file are of the same Autosar version */
40 #if ((CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MAJOR_VERSION    != CDD_PLATFORM_MRU_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
41      (CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MINOR_VERSION    != CDD_PLATFORM_MRU_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
42      (CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_AR_RELEASE_REVISION_VERSION != CDD_PLATFORM_MRU_IP_TYPES_AR_RELEASE_REVISION_VERSION) \
43     )
44      #error "AUTOSAR Version Numbers of Mpu_R52_Ip_TrustedFunctions.h and Mru_Ip_Types.h are different"
45 #endif
46 /* Check if Mpu_R52_Ip_TrustedFunctions.h file and Mpu_R52_Ip_Cfg.h file are of the same Software version */
47 #if ((CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_SW_MAJOR_VERSION != CDD_PLATFORM_MRU_IP_TYPES_SW_MAJOR_VERSION) || \
48      (CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_SW_MINOR_VERSION != CDD_PLATFORM_MRU_IP_TYPES_SW_MINOR_VERSION) || \
49      (CDD_PLATFORM_MPU_R52_IP_TRUSTEDFUNCTIONS_SW_PATCH_VERSION != CDD_PLATFORM_MRU_IP_TYPES_SW_PATCH_VERSION) \
50     )
51     #error "Software Version Numbers of Mpu_R52_Ip_TrustedFunctions.h and Mru_Ip_Types.h are different"
52 #endif
53 
54 /*==================================================================================================
55 *                                      FUNCTION PROTOTYPES
56 ==================================================================================================*/
57 
58 #if defined(__cplusplus)
59 extern "C" {
60 #endif
61 
62 #ifdef PLATFORM_IP_ENABLE_MRU
63 #if (PLATFORM_IP_ENABLE_MRU == STD_ON)
64 
65 #define PLATFORM_START_SEC_CODE
66 #include "Platform_MemMap.h"
67 
68 #if ((STD_ON == MRU_IP_ENABLE_USER_MODE_SUPPORT) && (defined (MCAL_ENABLE_USER_MODE_SUPPORT)))
69 /**
70 * @brief            MRU peripheral initialization.
71 * @details          The function initialize the MRU Unit specified in the configuration.
72 *
73 * @param[in]        HWUnitConfigPtr -  pointer to the specified MRU Unit configuration.
74 */
75 extern void Mru_Ip_Init_Privileged(const Mru_Ip_ConfigType *HWUnitConfigPtr);
76 
77 /**
78 * @brief            MRU transmission.
79 * @details          This function writes the data to Mailboxes using the channel specified.
80 *
81 * @param[in]        TransmitChCfgPtr - pointer to the channel configuration where contains list of mailboxes to be written.
82 * @param[in]        TxBufferPtr - pointer to transmit buffer.
83 *
84 * @return           MRU_IP_STATUS_SUCCESS: Transmission command has been accepted.
85 *                   MRU_IP_STATUS_FAIL: Transmission command has not been accepted.
86 */
87 extern Mru_Ip_StatusType Mru_Ip_Transmit_Privileged( const Mru_Ip_TransmitChannelType *TransmitChCfgPtr,
88                                                      const uint32 *TxBufferPtr
89                                                    );
90 #if (STD_ON == MRU_IP_CHANNEL_RESET_API)
91 /**
92 * @brief            MRU Reset transmit channel.
93 * @details          This function reset mailboxs status which are used by transmit channel in configuration.
94 *
95 * @param[in]        TransmitChCfgPtr - Pointer for the transmit channel configuration.
96 *
97 * @return           void
98 *
99 */
100 extern void Mru_Ip_ResetTransmitChannel_Privileged( const Mru_Ip_TransmitChannelType *TransmitChCfgPtr);
101 /**
102 * @brief            MRU Reset receive channel.
103 * @details          This function reset mailboxs status which are used by receive channel in configuration.
104 *
105 * @param[in]        ReceiveChCfgPtr - Pointer for the receive channel configuration.
106 *
107 * @return           void
108 *
109 */
110 extern void Mru_Ip_ResetReceiveChannel_Privileged( const Mru_Ip_ReceiveChannelType *ReceiveChCfgPtr );
111 #endif
112 
113 #if (STD_ON == MRU_IP_INSTANCE_RESET_API)
114 /**
115 * @brief            Reset Mru Instance.
116 * @details          This function reset all mailbox status in a Mru instance.
117 *
118 * @param[in]        ResetInsCfgPtr – Reset Mru instance configuration pointer.
119 *
120 * @return           void
121 *
122 */
123 extern void Mru_Ip_ResetInstance_Privileged( const Mru_Ip_ResetInstanceType *ResetInsCfgPtr );
124 #endif
125 
126 /**
127 * @brief            MRU Read Mailbox.
128 * @details          This function read the data from Mailboxes using the channel specified with polling mode.
129 *
130 * @param[in]        ReceiveChCfgPtr - Pointer for the receive channel configuration.
131 * @param[in]        RxBufferPtr - Buffer pointer to receive data.
132 * @param[in]        Timeout - time-out
133 *
134 * @return           MRU_IP_STATUS_SUCCESS: Receive command has been accepted.
135 *                   MRU_IP_STATUS_TIMEOUT: Receive command has been timeout.
136 */
137 extern Mru_Ip_StatusType Mru_Ip_ReadMailbox_Privileged( const Mru_Ip_ReceiveChannelType *ReceiveChCfgPtr,
138                                                         uint32 *RxBufferPtr,
139                                                         uint32 Timeout
140                                                       );
141 
142 /**
143 * @brief   Get mailbox status.
144 * @details This function get mailbox status of a specific channel.
145 *
146 * @param[in]      ReceiveChCfgPtr       Pointer for the receive channel configuration.
147 *
148 * @return Mru_Ip_MBStatusType
149 * @retval MRU_IP_MAILBOX_INACTIVE       Mailbox status is inactive
150 * @retval MRU_IP_MAILBOX_ACTIVE         Mailbox status is active
151 */
152 extern Mru_Ip_MBStatusType Mru_Ip_GetMailboxStatus_Privileged( const Mru_Ip_ReceiveChannelType *ReceiveChCfgPtr );
153 
154 #if (STD_ON == MRU_IP_CHANNEL_ENABLE_API)
155 /**
156 * @brief            MRU Enable channel.
157 * @details          This function enable interrupt capability of a logical receive channel.
158 *
159 * @param[in]        ReceiveChCfgPtr - Pointer for the receive channel configuration.
160 *
161 * @return           Mru_Ip_StatusType
162 * @retval           MRU_IP_STATUS_SUCCESS: Receive command has been accepted.
163 *                   MRU_IP_STATUS_FAIL: Receive command has not been accepted.
164 *
165 */
166 extern Mru_Ip_StatusType Mru_Ip_EnableChannel_Privileged( const Mru_Ip_ReceiveChannelType *ReceiveChCfgPtr);
167 #endif
168 
169 #if (STD_ON == MRU_IP_CHANNEL_DISABLE_API)
170 /**
171 * @brief            MRU Disable channel.
172 * @details          This function disable interrupt capability and Mru mailbox read functional of a logical receive channel.
173 *                   Before actual disabling logical Mru channel , Mru_Ip_DisableChannel
174 *                   will try to see if there is any on-going request is pending and execute it immediately.
175 *                   After disabling operation is done, any new request will be ignored.
176 *                   The pending interrupt inside interrupt controller cannot be cleared and will be treated like spurious interrupt.
177 *
178 * @param[in]        ReceiveChCfgPtr - Pointer for the receive channel configuration.
179 *
180 * @return           Mru_Ip_StatusType
181 * @retval           MRU_IP_STATUS_SUCCESS: Receive command has been accepted.
182 *                   MRU_IP_STATUS_FAIL: Receive command has not been accepted.
183 *
184 */
185 extern Mru_Ip_StatusType Mru_Ip_DisableChannel_Privileged( const Mru_Ip_ReceiveChannelType *ReceiveChCfgPtr);
186 #endif
187 
188 #endif /* MRU_IP_ENABLE_USER_MODE_SUPPORT == STD_ON */
189 #define PLATFORM_STOP_SEC_CODE
190 #include "Platform_MemMap.h"
191 
192 #endif /* PLATFORM_IP_ENABLE_MRU == STD_ON)*/
193 #endif /* PLATFORM_IP_ENABLE_MRU */
194 
195 #if defined(__cplusplus)
196 }
197 #endif /* __cplusplus*/
198 
199 /*! @} */
200 
201 #endif /* MRU_IP_TRUSTEDFUNCTIONS_H */
202