1 /*
2  * Copyright 2020-2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef POWER_IP_TRUSTEDFUNCTIONS_H
8 #define POWER_IP_TRUSTEDFUNCTIONS_H
9 
10 /**
11 *   @file    Power_Ip_TrustedFunctions.h
12 *   @version    3.0.0
13 *
14 *   @brief   POWER IP type header file.
15 *   @details POWER IP type header file.
16 
17 *   @addtogroup CLOCK_DRIVER Clock Ip Driver
18 *   @{
19 */
20 
21 #if defined(__cplusplus)
22 extern "C"{
23 #endif
24 /*==================================================================================================
25 *                                          INCLUDE FILES
26 * 1) system and project includes
27 * 2) needed interfaces from external units
28 * 3) internal and external interfaces from this unit
29 ==================================================================================================*/
30 #include "StandardTypes.h"
31 #include "Power_Ip_Cfg.h"
32 #include "Power_Ip_Specific.h"
33 #include "Power_Ip_Types.h"
34 #include "Mcal.h"
35 
36 /*==================================================================================================
37                                SOURCE FILE VERSION INFORMATION
38 ==================================================================================================*/
39 #define POWER_IP_TRUSTEDFUNCTIONS_VENDOR_ID                       43
40 #define POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MAJOR_VERSION        4
41 #define POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MINOR_VERSION        7
42 #define POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_REVISION_VERSION     0
43 #define POWER_IP_TRUSTEDFUNCTIONS_SW_MAJOR_VERSION                3
44 #define POWER_IP_TRUSTEDFUNCTIONS_SW_MINOR_VERSION                0
45 #define POWER_IP_TRUSTEDFUNCTIONS_SW_PATCH_VERSION                0
46 
47 /*==================================================================================================
48                                       FILE VERSION CHECKS
49 ==================================================================================================*/
50 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
51 /* Check if Power_Ip_TrustedFunctions.h file and StandardTypes.h file are of the same Autosar version */
52 #if ((POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MAJOR_VERSION    != STD_AR_RELEASE_MAJOR_VERSION) || \
53      (POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MINOR_VERSION    != STD_AR_RELEASE_MINOR_VERSION))
54     #error "AutoSar Version Numbers of Power_Ip_TrustedFunctions.h and StandardTypes.h are different"
55 #endif
56 #endif
57 
58 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
59 /* Check if Power_Ip_TrustedFunctions.h file and Mcal.h file are of the same Autosar version */
60 #if ((POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MAJOR_VERSION    != MCAL_AR_RELEASE_MAJOR_VERSION) || \
61      (POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MINOR_VERSION    != MCAL_AR_RELEASE_MINOR_VERSION))
62     #error "AutoSar Version Numbers of Power_Ip_TrustedFunctions.h and Mcal.h are different"
63 #endif
64 #endif
65 
66 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Cfg.h file have same versions */
67 #if (POWER_IP_TRUSTEDFUNCTIONS_VENDOR_ID  != POWER_IP_CFG_VENDOR_ID)
68     #error "Power_Ip_TrustedFunctions.h and Power_Ip_Cfg.h have different vendor IDs"
69 #endif
70 
71 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Cfg.h file are of the same Autosar version */
72 #if ((POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MAJOR_VERSION    != POWER_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \
73      (POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MINOR_VERSION    != POWER_IP_CFG_AR_RELEASE_MINOR_VERSION) || \
74      (POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_REVISION_VERSION != POWER_IP_CFG_AR_RELEASE_REVISION_VERSION))
75     #error "AutoSar Version Numbers of Power_Ip_TrustedFunctions.h and Power_Ip_Cfg.h are different"
76 #endif
77 
78 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Cfg.h file are of the same Software version */
79 #if ((POWER_IP_TRUSTEDFUNCTIONS_SW_MAJOR_VERSION != POWER_IP_CFG_SW_MAJOR_VERSION) || \
80      (POWER_IP_TRUSTEDFUNCTIONS_SW_MINOR_VERSION != POWER_IP_CFG_SW_MINOR_VERSION) || \
81      (POWER_IP_TRUSTEDFUNCTIONS_SW_PATCH_VERSION != POWER_IP_CFG_SW_PATCH_VERSION))
82     #error "Software Version Numbers of Power_Ip_TrustedFunctions.h and Power_Ip_Cfg.h are different"
83 #endif
84 
85 
86 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Specific.h file have same versions */
87 #if (POWER_IP_TRUSTEDFUNCTIONS_VENDOR_ID  != POWER_IP_SPECIFIC_VENDOR_ID)
88     #error "Power_Ip_TrustedFunctions.h and Power_Ip_Specific.h have different vendor IDs"
89 #endif
90 
91 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Specific.h file are of the same Autosar version */
92 #if ((POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MAJOR_VERSION    != POWER_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION) || \
93      (POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MINOR_VERSION    != POWER_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION) || \
94      (POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_REVISION_VERSION != POWER_IP_SPECIFIC_AR_RELEASE_REVISION_VERSION))
95     #error "AutoSar Version Numbers of Power_Ip_TrustedFunctions.h and Power_Ip_Specific.h are different"
96 #endif
97 
98 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Specific.h file are of the same Software version */
99 #if ((POWER_IP_TRUSTEDFUNCTIONS_SW_MAJOR_VERSION != POWER_IP_SPECIFIC_SW_MAJOR_VERSION) || \
100      (POWER_IP_TRUSTEDFUNCTIONS_SW_MINOR_VERSION != POWER_IP_SPECIFIC_SW_MINOR_VERSION) || \
101      (POWER_IP_TRUSTEDFUNCTIONS_SW_PATCH_VERSION != POWER_IP_SPECIFIC_SW_PATCH_VERSION))
102     #error "Software Version Numbers of Power_Ip_TrustedFunctions.h and Power_Ip_Specific.h are different"
103 #endif
104 
105 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Types.h file have same versions */
106 #if (POWER_IP_TRUSTEDFUNCTIONS_VENDOR_ID  != POWER_IP_TYPES_VENDOR_ID)
107     #error "Power_Ip_TrustedFunctions.h and Power_Ip_Types.h have different vendor IDs"
108 #endif
109 
110 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Types.h file are of the same Autosar version */
111 #if ((POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MAJOR_VERSION    != POWER_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
112      (POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_MINOR_VERSION    != POWER_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
113      (POWER_IP_TRUSTEDFUNCTIONS_AR_RELEASE_REVISION_VERSION != POWER_IP_TYPES_AR_RELEASE_REVISION_VERSION))
114     #error "AutoSar Version Numbers of Power_Ip_TrustedFunctions.h and Power_Ip_Types.h are different"
115 #endif
116 
117 /* Check if Power_Ip_TrustedFunctions.h file and Power_Ip_Types.h file are of the same Software version */
118 #if ((POWER_IP_TRUSTEDFUNCTIONS_SW_MAJOR_VERSION != POWER_IP_TYPES_SW_MAJOR_VERSION) || \
119      (POWER_IP_TRUSTEDFUNCTIONS_SW_MINOR_VERSION != POWER_IP_TYPES_SW_MINOR_VERSION) || \
120      (POWER_IP_TRUSTEDFUNCTIONS_SW_PATCH_VERSION != POWER_IP_TYPES_SW_PATCH_VERSION))
121     #error "Software Version Numbers of Power_Ip_TrustedFunctions.h and Power_Ip_Types.h are different"
122 #endif
123 /*==================================================================================================
124 *                                            CONSTANTS
125 ==================================================================================================*/
126 
127 /*==================================================================================================
128 *                                       DEFINES AND MACROS
129 ==================================================================================================*/
130 
131 /*==================================================================================================
132 *                                              ENUMS
133 ==================================================================================================*/
134 
135 /*==================================================================================================
136 *                                  STRUCTURES AND OTHER TYPEDEFS
137 ==================================================================================================*/
138 
139 /*==================================================================================================
140 *                                  GLOBAL VARIABLE DECLARATIONS
141 ==================================================================================================*/
142 
143 /*==================================================================================================
144 *                                       FUNCTION PROTOTYPES
145 ==================================================================================================*/
146 /* Clock start section code */
147 #define MCU_START_SEC_CODE
148 #include "Mcu_MemMap.h"
149 
150 #ifdef POWER_IP_ENABLE_USER_MODE_SUPPORT
151   #if (STD_ON == POWER_IP_ENABLE_USER_MODE_SUPPORT)
152 
153 #ifdef POWER_IP_SLEEPONEXIT_SUPPORT
154 #if (POWER_IP_SLEEPONEXIT_SUPPORT == STD_ON)
155 /**
156  * @brief        The function enables SLEEPONEXIT bit.
157  *
158  * @param        None
159  * @return       None
160  *
161  */
162 extern void Power_Ip_CM7_EnableSleepOnExit(void);
163 
164 /**
165  * @brief        The function disables SLEEPONEXIT bit.
166  *
167  * @param        None
168  * @return       None
169  *
170  */
171 extern void Power_Ip_CM7_DisableSleepOnExit(void);
172 
173 /**
174 * @brief        The function disable SLEEPDEEP bit.
175 *
176 * @param[in]    none
177 * @return void
178 */
179 extern void Power_Ip_CM7_DisableDeepSleep(void);
180 
181 /**
182 * @brief        The function enable SLEEPDEEP bit.
183 *
184 * @param[in]    none
185 * @return void
186 */
187 extern void Power_Ip_CM7_EnableDeepSleep(void);
188   #endif
189 #endif
190 
191 /**
192  * @brief        This function initializes the Reset parameters.
193  *
194  * @param        ConfigPtr   Pointer to the MC_RGM configuration structure.
195  * @return       None
196  *
197  */
198 extern void Power_Ip_MC_RGM_ResetInit(const Power_Ip_MC_RGM_ConfigType * ConfigPtr);
199 
200 
201 #if (defined(POWER_IP_PERFORM_RESET_API))
202   #if (POWER_IP_PERFORM_RESET_API == STD_ON)
203 /**
204  * @brief        This function performs a microcontroller reset.
205  *
206  * @param        ConfigPtr   Pointer to the MC_RGM configuration structure.
207  * @return       None
208  *
209  */
210 extern void Power_Ip_MC_RGM_PerformReset(const Power_Ip_MC_RGM_ConfigType * ConfigPtr);
211   #endif /* (POWER_IP_PERFORM_RESET_API == STD_ON) */
212 #endif
213 
214 /**
215  * @brief        This function returns the Reset reason.
216  *
217  * @param        None
218  * @return       Reason of the Reset event.
219  *
220  */
221 extern Power_Ip_ResetType Power_Ip_MC_RGM_GetResetReason(void);
222 
223 /**
224  * @brief        This function returns the Raw Reset value.
225  *
226  * @param        None
227  * @return       Implementation-specific value with the Reset status.
228  *
229  */
230 extern Power_Ip_RawResetType Power_Ip_MC_RGM_GetResetRawValue(void);
231 
232 #if (defined(POWER_IP_RESET_DURING_STANDBY_SUPPORTED))
233   #if (POWER_IP_RESET_DURING_STANDBY_SUPPORTED == STD_ON)
234     #if (defined(POWER_IP_ENTER_LOW_POWER_MODE))
235       #if (POWER_IP_ENTER_LOW_POWER_MODE == STD_ON)
236 /**
237  * @brief        This function returns whether a reset occurred during standby.
238  *
239  * @param        None
240  * @return       boolean
241  *
242  */
243 extern uint8 Power_Ip_MC_RGM_ResetDuringStandby(void);
244       #endif /*(POWER_IP_ENTER_LOW_POWER_MODE == STD_ON) */
245     #endif
246   #endif
247 #endif /* (POWER_IP_RESET_DURING_STANDBY_SUPPORTED == STD_ON) */
248 
249 #if (defined(POWER_IP_ENTER_LOW_POWER_MODE))
250   #if (POWER_IP_ENTER_LOW_POWER_MODE == STD_ON)
251 
252 /**
253  * @brief        This function prepares the PMC module for Standby/Low Power entry.
254  *
255  * @param        None
256  * @return       None
257  *
258  */
259 extern void Power_Ip_PMC_PrepareLowPowerEntry(void);
260 
261   #endif /* (POWER_IP_ENTER_LOW_POWER_MODE == STD_ON) */
262 #endif
263 
264 #if (defined(MCAL_MC_ME_REG_PROT_AVAILABLE))
265  #if (STD_ON == MCAL_MC_ME_REG_PROT_AVAILABLE)
266 
267 /**
268  * @brief        This function will enable writing in User mode by configuring REG_PROT
269  *
270  * @param        None
271  * @return       None
272  *
273  */
274 extern void Power_Ip_MC_ME_SetUserAccessAllowed(void);
275  #endif /* (STD_ON == MCAL_MC_ME_REG_PROT_AVAILABLE) */
276 #endif
277 
278 #if (defined(MCAL_PMC_REG_PROT_AVAILABLE))
279  #if (STD_ON == MCAL_PMC_REG_PROT_AVAILABLE)
280 /**
281  * @brief        This function will enable writing in User mode by configuring REG_PROT
282  *
283  * @param        None
284  * @return       None
285  *
286  */
287 extern void Power_Ip_PMC_SetUserAccessAllowed(void);
288  #endif /* (STD_ON == MCAL_PMC_REG_PROT_AVAILABLE) */
289 #endif
290 
291 #if (defined(POWER_IP_ENTER_LOW_POWER_MODE) && (POWER_IP_ENTER_LOW_POWER_MODE == STD_ON))
292 
293 #if (defined(MCAL_C40ASF_REG_PROT_AVAILABLE))
294   #if (STD_ON == MCAL_C40ASF_REG_PROT_AVAILABLE)
295 /**
296  * @brief        This function will enable writing in User mode by configuring REG_PROT
297  *
298  * @param        None
299  * @return       None
300  *
301  */
302 extern void Power_Ip_FLASH_C40ASF_SetUserAccessAllowed(void);
303   #endif /* (STD_ON == MCAL_C40ASF_REG_PROT_AVAILABLE) */
304 #endif /* (MCAL_C40ASF_REG_PROT_AVAILABLE) */
305 
306 #endif /* (POWER_IP_ENTER_LOW_POWER_MODE == STD_ON) */
307 
308 #if (defined(MCAL_MC_RGM_REG_PROT_AVAILABLE))
309   #if (STD_ON == MCAL_MC_RGM_REG_PROT_AVAILABLE)
310 /**
311  * @brief        This function will enable writing in User mode by configuring REG_PROT
312  *
313  * @param        None
314  * @return       None
315  *
316  */
317 extern void Power_Ip_MC_RGM_SetUserAccessAllowed(void);
318   #endif /* (STD_ON == MCAL_MC_RGM_REG_PROT_AVAILABLE) */
319 #endif
320 
321 #if (defined(MCAL_RDC_REG_PROT_AVAILABLE))
322  #if (STD_ON == MCAL_RDC_REG_PROT_AVAILABLE)
323 
324 /**
325  * @brief        This function will enable writing in User mode by configuring REG_PROT
326  *
327  * @param        None
328  * @return       None
329  *
330  */
331 extern void Power_Ip_RDC_SetUserAccessAllowed(void);
332  #endif /* (STD_ON == MCAL_RDC_REG_PROT_AVAILABLE) */
333 #endif
334 
335 #if (defined(MCAL_DCM_REG_PROT_AVAILABLE))
336  #if (STD_ON == MCAL_DCM_REG_PROT_AVAILABLE)
337 
338 /**
339  * @brief        This function will enable writing in User mode by configuring REG_PROT
340  *
341  * @param        None
342  * @return       None
343  *
344  */
345 extern void Power_Ip_DCM_GPR_SetUserAccessAllowed(void);
346  #endif /* (STD_ON == MCAL_DCM_REG_PROT_AVAILABLE) */
347 #endif
348   #endif
349 #endif /* POWER_IP_ENABLE_USER_MODE_SUPPORT */
350 
351 /* Clock stop section code */
352 #define MCU_STOP_SEC_CODE
353 #include "Mcu_MemMap.h"
354 
355 #if defined(__cplusplus)
356 }
357 #endif /* __cplusplus*/
358 
359 /*! @}*/
360 
361 #endif /* CLOCK_IP_TRUSTEDFUNCTIONS_H */
362 
363 
364