1 /*
2  * Copyright 2020-2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 /**
7 *   @file       Clock_Ip_Selector.c
8 *   @version    2.0.0
9 *
10 *   @brief   CLOCK driver implementations.
11 *   @details CLOCK driver implementations.
12 *
13 *   @addtogroup CLOCK_DRIVER Clock Ip Driver
14 *   @{
15 */
16 
17 
18 #ifdef __cplusplus
19 extern "C"{
20 #endif
21 
22 
23 /*==================================================================================================
24 *                                          INCLUDE FILES
25 * 1) system and project includes
26 * 2) needed interfaces from external units
27 * 3) internal and external interfaces from this unit
28 ==================================================================================================*/
29 
30 #include "Clock_Ip_Private.h"
31 
32 /*==================================================================================================
33                                SOURCE FILE VERSION INFORMATION
34 ==================================================================================================*/
35 #define CLOCK_IP_SELECTOR_VENDOR_ID_C                      43
36 #define CLOCK_IP_SELECTOR_AR_RELEASE_MAJOR_VERSION_C       4
37 #define CLOCK_IP_SELECTOR_AR_RELEASE_MINOR_VERSION_C       7
38 #define CLOCK_IP_SELECTOR_AR_RELEASE_REVISION_VERSION_C    0
39 #define CLOCK_IP_SELECTOR_SW_MAJOR_VERSION_C               2
40 #define CLOCK_IP_SELECTOR_SW_MINOR_VERSION_C               0
41 #define CLOCK_IP_SELECTOR_SW_PATCH_VERSION_C               0
42 
43 /*==================================================================================================
44 *                                     FILE VERSION CHECKS
45 ==================================================================================================*/
46 /* Check if Clock_Ip_Selector.c file and Clock_Ip_Private.h file are of the same vendor */
47 #if (CLOCK_IP_SELECTOR_VENDOR_ID_C != CLOCK_IP_PRIVATE_VENDOR_ID)
48     #error "Clock_Ip_Selector.c and Clock_Ip_Private.h have different vendor ids"
49 #endif
50 
51 /* Check if Clock_Ip_Selector.c file and Clock_Ip_Private.h file are of the same Autosar version */
52 #if ((CLOCK_IP_SELECTOR_AR_RELEASE_MAJOR_VERSION_C != CLOCK_IP_PRIVATE_AR_RELEASE_MAJOR_VERSION) || \
53      (CLOCK_IP_SELECTOR_AR_RELEASE_MINOR_VERSION_C != CLOCK_IP_PRIVATE_AR_RELEASE_MINOR_VERSION) || \
54      (CLOCK_IP_SELECTOR_AR_RELEASE_REVISION_VERSION_C != CLOCK_IP_PRIVATE_AR_RELEASE_REVISION_VERSION) \
55     )
56     #error "AutoSar Version Numbers of Clock_Ip_Selector.c and Clock_Ip_Private.h are different"
57 #endif
58 
59 /* Check if Clock_Ip_Selector.c file and Clock_Ip_Private.h file are of the same Software version */
60 #if ((CLOCK_IP_SELECTOR_SW_MAJOR_VERSION_C != CLOCK_IP_PRIVATE_SW_MAJOR_VERSION) || \
61      (CLOCK_IP_SELECTOR_SW_MINOR_VERSION_C != CLOCK_IP_PRIVATE_SW_MINOR_VERSION) || \
62      (CLOCK_IP_SELECTOR_SW_PATCH_VERSION_C != CLOCK_IP_PRIVATE_SW_PATCH_VERSION) \
63     )
64     #error "Software Version Numbers of Clock_Ip_Selector.c and Clock_Ip_Private.h are different"
65 #endif
66 /*==================================================================================================
67 *                           LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
68 ==================================================================================================*/
69 
70 /*==================================================================================================
71 *                                          LOCAL MACROS
72 ==================================================================================================*/
73 
74 /*==================================================================================================
75 *                                         LOCAL CONSTANTS
76 ==================================================================================================*/
77 
78 /*==================================================================================================
79 *                                         LOCAL VARIABLES
80 ==================================================================================================*/
81 
82 /*==================================================================================================
83 *                                        GLOBAL CONSTANTS
84 ==================================================================================================*/
85 
86 /*==================================================================================================
87 *                                        GLOBAL VARIABLES
88 ==================================================================================================*/
89 
90 /*==================================================================================================
91 *                                    GLOBAL FUNCTION PROTOTYPES
92 ==================================================================================================*/
93 /* Clock start section code */
94 #define MCU_START_SEC_CODE
95 
96 #include "Mcu_MemMap.h"
97 
98 #ifdef CLOCK_IP_SCG_SCS_RUN_SEL
99 void Clock_Ip_ResetScgRunSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
100 void Clock_Ip_SetScgRunSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
101 #endif
102 
103 #ifdef CLOCK_IP_SCG_SCS_VLPR_SEL
104 void Clock_Ip_SetScgVlprSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
105 #endif
106 
107 #ifdef CLOCK_IP_SCG_SCS_HSRUN_SEL
108 void Clock_Ip_ResetScgHsrunSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
109 void Clock_Ip_SetScgHsrunSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
110 #endif
111 
112 #ifdef CLOCK_IP_SIM_RTC_SEL
113 void Clock_Ip_ResetSimRtcSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
114 void Clock_Ip_SetSimRtcSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
115 #endif
116 
117 #ifdef CLOCK_IP_SIM_LPO_SEL
118 void Clock_Ip_ResetSimLpoSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
119 void Clock_Ip_SetSimLpoSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
120 #endif
121 
122 #ifdef CLOCK_IP_SCG_CLKOUT_SEL
123 void Clock_Ip_ResetScgClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
124 void Clock_Ip_SetScgClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
125 #endif
126 
127 #ifdef CLOCK_IP_SIM_FTMOPT_SEL
128 void Clock_Ip_ResetSimFtmoptSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
129 void Clock_Ip_SetSimFtmoptSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
130 #endif
131 
132 #ifdef CLOCK_IP_SIM_CLKOUT_SEL
133 /* Clear CLKOUTSEL and CLKOUTEN bit field in SIM_CHIPCTL register  */
134 void Clock_Ip_ResetSimClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
135 void Clock_Ip_SetSimClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
136 #endif
137 
138 #ifdef CLOCK_IP_PCC_PCS_SELECT
139 void Clock_Ip_ResetPccPcsSelect_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
140 void Clock_Ip_SetPccPcsSelect_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
141 #endif
142 
143 #ifdef CLOCK_IP_SIM_TRACE_SEL
144 void Clock_Ip_ResetSimTraceSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
145 void Clock_Ip_SetSimTraceSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config);
146 #endif
147 
148 /*==================================================================================================
149 *                                    LOCAL FUNCTION PROTOTYPES
150 ==================================================================================================*/
151 
152 static void Clock_Ip_CallbackSelectorEmpty(Clock_Ip_SelectorConfigType const* Config);
153 
154 #ifdef CLOCK_IP_SIM_RTC_SEL
155 static void Clock_Ip_ResetSimRtcSel(Clock_Ip_SelectorConfigType const *Config);
156 static void Clock_Ip_SetSimRtcSel(Clock_Ip_SelectorConfigType const *Config);
157 #endif
158 
159 #ifdef CLOCK_IP_SIM_LPO_SEL
160 static void Clock_Ip_ResetSimLpoSel(Clock_Ip_SelectorConfigType const *Config);
161 static void Clock_Ip_SetSimLpoSel(Clock_Ip_SelectorConfigType const *Config);
162 #endif
163 
164 #ifdef CLOCK_IP_SCG_CLKOUT_SEL
165 static void Clock_Ip_ResetScgClkoutSel(Clock_Ip_SelectorConfigType const *Config);
166 static void Clock_Ip_SetScgClkoutSel(Clock_Ip_SelectorConfigType const *Config);
167 #endif
168 
169 #ifdef CLOCK_IP_SCG_SCS_RUN_SEL
170 static void Clock_Ip_ResetScgRunSel(Clock_Ip_SelectorConfigType const *Config);
171 static void Clock_Ip_SetScgRunSel(Clock_Ip_SelectorConfigType const *Config);
172 #endif
173 
174 #ifdef CLOCK_IP_SCG_SCS_VLPR_SEL
175 static void Clock_Ip_SetScgVlprSel(Clock_Ip_SelectorConfigType const *Config);
176 #endif
177 
178 #ifdef CLOCK_IP_SCG_SCS_HSRUN_SEL
179 static void Clock_Ip_ResetScgHsrunSel(Clock_Ip_SelectorConfigType const *Config);
180 static void Clock_Ip_SetScgHsrunSel(Clock_Ip_SelectorConfigType const *Config);
181 #endif
182 
183 #ifdef CLOCK_IP_SIM_FTMOPT_SEL
184 static void Clock_Ip_ResetSimFtmoptSel(Clock_Ip_SelectorConfigType const *Config);
185 static void Clock_Ip_SetSimFtmoptSel(Clock_Ip_SelectorConfigType const *Config);
186 #endif
187 
188 #ifdef CLOCK_IP_SIM_CLKOUT_SEL
189 static void Clock_Ip_ResetSimClkoutSel(Clock_Ip_SelectorConfigType const *Config);
190 static void Clock_Ip_SetSimClkoutSel(Clock_Ip_SelectorConfigType const *Config);
191 #endif
192 
193 #ifdef CLOCK_IP_PCC_PCS_SELECT
194 static void Clock_Ip_ResetPccPcsSelect(Clock_Ip_SelectorConfigType const *Config);
195 static void Clock_Ip_SetPccPcsSelect(Clock_Ip_SelectorConfigType const *Config);
196 #endif
197 
198 #ifdef CLOCK_IP_SIM_TRACE_SEL
199 static void Clock_Ip_ResetSimTraceSel(Clock_Ip_SelectorConfigType const *Config);
200 static void Clock_Ip_SetSimTraceSel(Clock_Ip_SelectorConfigType const *Config);
201 #endif
202 
203 /* Clock stop section code */
204 #define MCU_STOP_SEC_CODE
205 
206 #include "Mcu_MemMap.h"
207 /*==================================================================================================
208 *                                         LOCAL FUNCTIONS
209 ==================================================================================================*/
210 /* Clock start section code */
211 #define MCU_START_SEC_CODE
212 
213 #include "Mcu_MemMap.h"
214 
Clock_Ip_CallbackSelectorEmpty(Clock_Ip_SelectorConfigType const * Config)215 static void Clock_Ip_CallbackSelectorEmpty(Clock_Ip_SelectorConfigType const* Config)
216 {
217     (void)Config;
218     /* No implementation */
219 }
220 
221 #ifdef CLOCK_IP_SCG_SCS_RUN_SEL
Clock_Ip_ResetScgRunSel(Clock_Ip_SelectorConfigType const * Config)222 static void Clock_Ip_ResetScgRunSel(Clock_Ip_SelectorConfigType const *Config)
223 {
224     if (NULL_PTR != Config)
225     {
226     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
227       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
228         OsIf_Trusted_Call1param(Clock_Ip_ResetScgRunSel_TrustedCall,(Config));
229       #else
230         Clock_Ip_ResetScgRunSel_TrustedCall(Config);
231       #endif
232     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
233     }
234 }
235 
Clock_Ip_SetScgRunSel(Clock_Ip_SelectorConfigType const * Config)236 static void Clock_Ip_SetScgRunSel(Clock_Ip_SelectorConfigType const *Config)
237 {
238     if (NULL_PTR != Config)
239     {
240     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
241       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
242         OsIf_Trusted_Call1param(Clock_Ip_SetScgRunSel_TrustedCall,(Config));
243       #else
244         Clock_Ip_SetScgRunSel_TrustedCall(Config);
245       #endif
246     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
247     }
248 }
249 
250 #endif
251 
252 #ifdef CLOCK_IP_SCG_SCS_VLPR_SEL
Clock_Ip_SetScgVlprSel(Clock_Ip_SelectorConfigType const * Config)253 static void Clock_Ip_SetScgVlprSel(Clock_Ip_SelectorConfigType const *Config)
254 {
255     if (NULL_PTR != Config)
256     {
257     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
258       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
259         OsIf_Trusted_Call1param(Clock_Ip_SetScgVlprSel_TrustedCall,(Config));
260       #else
261         Clock_Ip_SetScgVlprSel_TrustedCall(Config);
262       #endif
263     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
264     }
265 }
266 
267 #endif
268 
269 #ifdef CLOCK_IP_SCG_SCS_HSRUN_SEL
Clock_Ip_ResetScgHsrunSel(Clock_Ip_SelectorConfigType const * Config)270 static void Clock_Ip_ResetScgHsrunSel(Clock_Ip_SelectorConfigType const *Config)
271 {
272     if (NULL_PTR != Config)
273     {
274     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
275       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
276         OsIf_Trusted_Call1param(Clock_Ip_ResetScgHsrunSel_TrustedCall,(Config));
277       #else
278         Clock_Ip_ResetScgHsrunSel_TrustedCall(Config);
279       #endif
280     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
281     }
282 }
Clock_Ip_SetScgHsrunSel(Clock_Ip_SelectorConfigType const * Config)283 static void Clock_Ip_SetScgHsrunSel(Clock_Ip_SelectorConfigType const *Config)
284 {
285     if (NULL_PTR != Config)
286     {
287     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
288       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
289         OsIf_Trusted_Call1param(Clock_Ip_SetScgHsrunSel_TrustedCall,(Config));
290       #else
291         Clock_Ip_SetScgHsrunSel_TrustedCall(Config);
292       #endif
293     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
294     }
295 }
296 #endif
297 
298 #ifdef CLOCK_IP_SIM_RTC_SEL
Clock_Ip_ResetSimRtcSel(Clock_Ip_SelectorConfigType const * Config)299 static void Clock_Ip_ResetSimRtcSel(Clock_Ip_SelectorConfigType const *Config)
300 {
301     if (NULL_PTR != Config)
302     {
303     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
304       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
305         OsIf_Trusted_Call1param(Clock_Ip_ResetSimRtcSel_TrustedCall,(Config));
306       #else
307         Clock_Ip_ResetSimRtcSel_TrustedCall(Config);
308       #endif
309     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
310     }
311 }
Clock_Ip_SetSimRtcSel(Clock_Ip_SelectorConfigType const * Config)312 static void Clock_Ip_SetSimRtcSel(Clock_Ip_SelectorConfigType const *Config)
313 {
314     if (NULL_PTR != Config)
315     {
316     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
317       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
318         OsIf_Trusted_Call1param(Clock_Ip_SetSimRtcSel_TrustedCall,(Config));
319       #else
320         Clock_Ip_SetSimRtcSel_TrustedCall(Config);
321       #endif
322     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
323     }
324 }
325 #endif
326 
327 #ifdef CLOCK_IP_SIM_LPO_SEL
Clock_Ip_ResetSimLpoSel(Clock_Ip_SelectorConfigType const * Config)328 static void Clock_Ip_ResetSimLpoSel(Clock_Ip_SelectorConfigType const *Config)
329 {
330     if (NULL_PTR != Config)
331     {
332     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
333       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
334         OsIf_Trusted_Call1param(Clock_Ip_ResetSimLpoSel_TrustedCall,(Config));
335       #else
336         Clock_Ip_ResetSimLpoSel_TrustedCall(Config);
337       #endif
338     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
339     }
340 }
Clock_Ip_SetSimLpoSel(Clock_Ip_SelectorConfigType const * Config)341 static void Clock_Ip_SetSimLpoSel(Clock_Ip_SelectorConfigType const *Config)
342 {
343     if (NULL_PTR != Config)
344     {
345     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
346       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
347         OsIf_Trusted_Call1param(Clock_Ip_SetSimLpoSel_TrustedCall,(Config));
348       #else
349         Clock_Ip_SetSimLpoSel_TrustedCall(Config);
350       #endif
351     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
352     }
353 }
354 #endif
355 
356 #ifdef CLOCK_IP_SCG_CLKOUT_SEL
Clock_Ip_ResetScgClkoutSel(Clock_Ip_SelectorConfigType const * Config)357 static void Clock_Ip_ResetScgClkoutSel(Clock_Ip_SelectorConfigType const *Config)
358 {
359     if (NULL_PTR != Config)
360     {
361     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
362       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
363         OsIf_Trusted_Call1param(Clock_Ip_ResetScgClkoutSel_TrustedCall,(Config));
364       #else
365         Clock_Ip_ResetScgClkoutSel_TrustedCall(Config);
366       #endif
367     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
368     }
369 }
Clock_Ip_SetScgClkoutSel(Clock_Ip_SelectorConfigType const * Config)370 static void Clock_Ip_SetScgClkoutSel(Clock_Ip_SelectorConfigType const *Config)
371 {
372     if (NULL_PTR != Config)
373     {
374     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
375       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
376         OsIf_Trusted_Call1param(Clock_Ip_SetScgClkoutSel_TrustedCall,(Config));
377       #else
378         Clock_Ip_SetScgClkoutSel_TrustedCall(Config);
379       #endif
380     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
381     }
382 }
383 #endif
384 
385 #ifdef CLOCK_IP_SIM_FTMOPT_SEL
Clock_Ip_ResetSimFtmoptSel(Clock_Ip_SelectorConfigType const * Config)386 static void Clock_Ip_ResetSimFtmoptSel(Clock_Ip_SelectorConfigType const *Config)
387 {
388     if (NULL_PTR != Config)
389     {
390     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
391       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
392         OsIf_Trusted_Call1param(Clock_Ip_ResetSimFtmoptSel_TrustedCall,(Config));
393       #else
394         Clock_Ip_ResetSimFtmoptSel_TrustedCall(Config);
395       #endif
396     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
397     }
398 }
Clock_Ip_SetSimFtmoptSel(Clock_Ip_SelectorConfigType const * Config)399 static void Clock_Ip_SetSimFtmoptSel(Clock_Ip_SelectorConfigType const *Config)
400 {
401     if (NULL_PTR != Config)
402     {
403     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
404       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
405         OsIf_Trusted_Call1param(Clock_Ip_SetSimFtmoptSel_TrustedCall,(Config));
406       #else
407         Clock_Ip_SetSimFtmoptSel_TrustedCall(Config);
408       #endif
409     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
410     }
411 }
412 #endif
413 
414 #ifdef CLOCK_IP_SIM_CLKOUT_SEL
Clock_Ip_ResetSimClkoutSel(Clock_Ip_SelectorConfigType const * Config)415 static void Clock_Ip_ResetSimClkoutSel(Clock_Ip_SelectorConfigType const *Config)
416 {
417     if (NULL_PTR != Config)
418     {
419     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
420       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
421         OsIf_Trusted_Call1param(Clock_Ip_ResetSimClkoutSel_TrustedCall,(Config));
422       #else
423         Clock_Ip_ResetSimClkoutSel_TrustedCall(Config);
424       #endif
425     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
426     }
427 }
Clock_Ip_SetSimClkoutSel(Clock_Ip_SelectorConfigType const * Config)428 static void Clock_Ip_SetSimClkoutSel(Clock_Ip_SelectorConfigType const *Config)
429 {
430     if (NULL_PTR != Config)
431     {
432     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
433       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
434         OsIf_Trusted_Call1param(Clock_Ip_SetSimClkoutSel_TrustedCall,(Config));
435       #else
436         Clock_Ip_SetSimClkoutSel_TrustedCall(Config);
437       #endif
438     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
439     }
440 }
441 #endif
442 
443 #ifdef CLOCK_IP_PCC_PCS_SELECT
Clock_Ip_ResetPccPcsSelect(Clock_Ip_SelectorConfigType const * Config)444 static void Clock_Ip_ResetPccPcsSelect(Clock_Ip_SelectorConfigType const *Config)
445 {
446     if (NULL_PTR != Config)
447     {
448     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
449       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
450         OsIf_Trusted_Call1param(Clock_Ip_ResetPccPcsSelect_TrustedCall,(Config));
451       #else
452         Clock_Ip_ResetPccPcsSelect_TrustedCall(Config);
453       #endif
454     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
455     }
456 }
Clock_Ip_SetPccPcsSelect(Clock_Ip_SelectorConfigType const * Config)457 static void Clock_Ip_SetPccPcsSelect(Clock_Ip_SelectorConfigType const *Config)
458 {
459     if (NULL_PTR != Config)
460     {
461     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
462       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
463         OsIf_Trusted_Call1param(Clock_Ip_SetPccPcsSelect_TrustedCall,(Config));
464       #else
465         Clock_Ip_SetPccPcsSelect_TrustedCall(Config);
466       #endif
467     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
468     }
469 }
470 #endif
471 
472 #ifdef CLOCK_IP_SIM_TRACE_SEL
Clock_Ip_ResetSimTraceSel(Clock_Ip_SelectorConfigType const * Config)473 static void Clock_Ip_ResetSimTraceSel(Clock_Ip_SelectorConfigType const *Config)
474 {
475     if (NULL_PTR != Config)
476     {
477     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
478       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
479         OsIf_Trusted_Call1param(Clock_Ip_ResetSimTraceSel_TrustedCall,(Config));
480       #else
481         Clock_Ip_ResetSimTraceSel_TrustedCall(Config);
482       #endif
483     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
484     }
485 }
Clock_Ip_SetSimTraceSel(Clock_Ip_SelectorConfigType const * Config)486 static void Clock_Ip_SetSimTraceSel(Clock_Ip_SelectorConfigType const *Config)
487 {
488     if (NULL_PTR != Config)
489     {
490     #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
491       #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
492         OsIf_Trusted_Call1param(Clock_Ip_SetSimTraceSel_TrustedCall,(Config));
493       #else
494         Clock_Ip_SetSimTraceSel_TrustedCall(Config);
495       #endif
496     #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
497     }
498 }
499 #endif
500 
501 /*==================================================================================================
502 *                                        GLOBAL FUNCTIONS
503 ==================================================================================================*/
504 #ifdef CLOCK_IP_SCG_SCS_RUN_SEL
Clock_Ip_ResetScgRunSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)505 void Clock_Ip_ResetScgRunSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
506 {
507     uint32 RegValue;
508     uint32 SelectorValue = Clock_Ip_au8SelectorEntryScsHardwareValue[FIRC_CLK];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
509 
510     (void)Config;
511 
512     RegValue = IP_SCG->RCCR;
513     RegValue &= ~SCG_RCCR_SCS_MASK;
514     RegValue |= SCG_RCCR_SCS(SelectorValue);
515     IP_SCG->RCCR = RegValue;
516 }
517 
Clock_Ip_SetScgRunSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)518 void Clock_Ip_SetScgRunSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
519 {
520     uint32 RegValue;
521     uint32 SelectorValue = Clock_Ip_au8SelectorEntryScsHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
522 
523     RegValue = IP_SCG->RCCR;
524     RegValue &= ~SCG_RCCR_SCS_MASK;
525     RegValue |= SCG_RCCR_SCS(SelectorValue);
526     IP_SCG->RCCR = RegValue;
527 }
528 #endif
529 
530 #ifdef CLOCK_IP_SCG_SCS_VLPR_SEL
531 
Clock_Ip_SetScgVlprSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)532 void Clock_Ip_SetScgVlprSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
533 {
534     uint32 RegValue;
535     uint32 SelectorValue = Clock_Ip_au8SelectorEntryScsHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
536 
537     RegValue = IP_SCG->VCCR;
538     RegValue &= ~SCG_VCCR_SCS_MASK;
539     RegValue |= SCG_VCCR_SCS(SelectorValue);
540     IP_SCG->VCCR = RegValue;
541 }
542 
543 #endif
544 
545 #ifdef CLOCK_IP_SCG_SCS_HSRUN_SEL
Clock_Ip_ResetScgHsrunSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)546 void Clock_Ip_ResetScgHsrunSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
547 {
548     uint32 RegValue;
549     uint32 SelectorValue = Clock_Ip_au8SelectorEntryScsHardwareValue[FIRC_CLK];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
550 
551     (void)Config;
552 
553     RegValue = IP_SCG->HCCR;
554     RegValue &= ~SCG_HCCR_SCS_MASK;
555     RegValue |= SCG_HCCR_SCS(SelectorValue);
556     IP_SCG->HCCR = RegValue;
557 }
Clock_Ip_SetScgHsrunSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)558 void Clock_Ip_SetScgHsrunSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
559 {
560     uint32 RegValue;
561     uint32 SelectorValue = Clock_Ip_au8SelectorEntryScsHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
562 
563     RegValue = IP_SCG->HCCR;
564     RegValue &= ~SCG_HCCR_SCS_MASK;
565     RegValue |= SCG_HCCR_SCS(SelectorValue);
566     IP_SCG->HCCR = RegValue;
567 }
568 #endif
569 
570 #ifdef CLOCK_IP_SIM_RTC_SEL
Clock_Ip_ResetSimRtcSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)571 void Clock_Ip_ResetSimRtcSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
572 {
573     uint32 RegValue;
574     uint32 SelectorValue = Clock_Ip_au16SelectorEntryHardwareValue[SOSCDIV1_CLK];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
575 
576     (void)Config;
577 
578     RegValue = IP_SIM->LPOCLKS;
579     RegValue &= ~SIM_LPOCLKS_RTCCLKSEL_MASK;
580     RegValue |= (SelectorValue << SIM_LPOCLKS_RTCCLKSEL_SHIFT);
581     IP_SIM->LPOCLKS = RegValue;
582 }
583 
Clock_Ip_SetSimRtcSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)584 void Clock_Ip_SetSimRtcSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
585 {
586     uint32 RegValue;
587     uint32 SelectorValue = Clock_Ip_au16SelectorEntryHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
588 
589     RegValue = IP_SIM->LPOCLKS;
590     RegValue &= ~SIM_LPOCLKS_RTCCLKSEL_MASK;
591     RegValue |= (SelectorValue << SIM_LPOCLKS_RTCCLKSEL_SHIFT);
592     IP_SIM->LPOCLKS = RegValue;
593 }
594 #endif
595 
596 #ifdef CLOCK_IP_SIM_LPO_SEL
Clock_Ip_ResetSimLpoSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)597 void Clock_Ip_ResetSimLpoSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
598 {
599     uint32 RegValue;
600     uint32 SelectorValue = Clock_Ip_au8SelectorEntrySIMHardwareValue[LPO_128K_CLK];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
601 
602     (void)Config;
603 
604     RegValue = IP_SIM->LPOCLKS;
605     RegValue &= ~SIM_LPOCLKS_LPOCLKSEL_MASK;
606     RegValue |= (SelectorValue << SIM_LPOCLKS_LPOCLKSEL_SHIFT);
607     IP_SIM->LPOCLKS = RegValue;
608 }
Clock_Ip_SetSimLpoSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)609 void Clock_Ip_SetSimLpoSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
610 {
611     uint32 RegValue;
612     /* LPO_CLK selector mapped to Clock_Ip_au8SelectorEntrySIMHardwareValue */
613     uint32 SelectorValue = Clock_Ip_au8SelectorEntrySIMHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
614 
615     (void)Config;
616 
617     RegValue = IP_SIM->LPOCLKS;
618     RegValue &= ~SIM_LPOCLKS_LPOCLKSEL_MASK;
619     RegValue |= (SelectorValue << SIM_LPOCLKS_LPOCLKSEL_SHIFT);
620     IP_SIM->LPOCLKS = RegValue;
621 }
622 #endif
623 
624 #ifdef CLOCK_IP_SCG_CLKOUT_SEL
Clock_Ip_ResetScgClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)625 void Clock_Ip_ResetScgClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
626 {
627     uint32 RegValue;
628     /* LPO_CLK selector mapped to Clock_Ip_au8SelectorEntryScsHardwareValue */
629     uint32 SelectorValue = Clock_Ip_au8SelectorEntryScsHardwareValue[FIRC_CLK];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
630 
631     (void)Config;
632 
633     RegValue = IP_SCG->CLKOUTCNFG;
634     RegValue &= ~SCG_CLKOUTCNFG_CLKOUTSEL_MASK;
635     RegValue |= (SelectorValue << SCG_CLKOUTCNFG_CLKOUTSEL_SHIFT);
636     IP_SCG->CLKOUTCNFG = RegValue;
637 }
Clock_Ip_SetScgClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)638 void Clock_Ip_SetScgClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
639 {
640     uint32 RegValue;
641     uint32 SelectorValue = Clock_Ip_au8SelectorEntryScsHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
642 
643     RegValue = IP_SCG->CLKOUTCNFG;
644     RegValue &= ~SCG_CLKOUTCNFG_CLKOUTSEL_MASK;
645     RegValue |= (SelectorValue << SCG_CLKOUTCNFG_CLKOUTSEL_SHIFT);
646     IP_SCG->CLKOUTCNFG = RegValue;
647 }
648 #endif
649 
650 #ifdef CLOCK_IP_SIM_FTMOPT_SEL
651 #define SIM_FTMOPT0_FTM_0_3_CLKSEL_SHIFT(x)  (24U + ((x) << 1U))
652 #define SIM_FTMOPT0_FTM_0_3_CLKSEL_MASK(x)   ((uint32)3U << SIM_FTMOPT0_FTM_0_3_CLKSEL_SHIFT(x))
653 #define SIM_FTMOPT0_FTM_4_7_CLKSEL_SHIFT(x)  (16U + (((x) - 4U) << 1U))
654 #define SIM_FTMOPT0_FTM_4_7_CLKSEL_MASK(x)   ((uint32)3U << SIM_FTMOPT0_FTM_4_7_CLKSEL_SHIFT(x))
Clock_Ip_ResetSimFtmoptSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)655 void Clock_Ip_ResetSimFtmoptSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
656 {
657     uint32 RegValue;
658     uint32 SelectorValue = Clock_Ip_au16SelectorEntryHardwareValue[FIRC_CLK];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
659     uint32 Instance      = Clock_Ip_au8ClockFeatures[Config->Name][CLOCK_IP_MODULE_INSTANCE];
660 
661     RegValue = IP_SIM->FTMOPT0;
662     if(Instance < 4U)
663     {
664         RegValue &= ~(SIM_FTMOPT0_FTM_0_3_CLKSEL_MASK(Instance));
665         RegValue |= (SelectorValue << SIM_FTMOPT0_FTM_0_3_CLKSEL_SHIFT(Instance));
666     }
667     else
668     {
669         RegValue &= ~(SIM_FTMOPT0_FTM_4_7_CLKSEL_MASK(Instance));
670         RegValue |= (SelectorValue << SIM_FTMOPT0_FTM_4_7_CLKSEL_SHIFT(Instance));
671     }
672 
673     IP_SIM->FTMOPT0 = RegValue;
674 }
Clock_Ip_SetSimFtmoptSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)675 void Clock_Ip_SetSimFtmoptSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
676 {
677     uint32 RegValue;
678     uint32 SelectorValue = Clock_Ip_au16SelectorEntryHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
679     uint32 Instance      = Clock_Ip_au8ClockFeatures[Config->Name][CLOCK_IP_MODULE_INSTANCE];
680 
681     RegValue = IP_SIM->FTMOPT0;
682     if(Instance < 4U)
683     {
684         RegValue &= ~(SIM_FTMOPT0_FTM_0_3_CLKSEL_MASK(Instance));
685         RegValue |= (SelectorValue << SIM_FTMOPT0_FTM_0_3_CLKSEL_SHIFT(Instance));
686     }
687     else
688     {
689         RegValue &= ~(SIM_FTMOPT0_FTM_4_7_CLKSEL_MASK(Instance));
690         RegValue |= (SelectorValue << SIM_FTMOPT0_FTM_4_7_CLKSEL_SHIFT(Instance));
691     }
692 
693     IP_SIM->FTMOPT0 = RegValue;
694 }
695 #endif
696 
697 #ifdef CLOCK_IP_SIM_CLKOUT_SEL
698 /* Clear CLKOUTSEL and CLKOUTEN bit field in SIM_CHIPCTL register  */
Clock_Ip_ResetSimClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)699 void Clock_Ip_ResetSimClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
700 {
701     uint32 RegValue;
702 
703     (void)Config;
704 
705     RegValue = IP_SIM->CHIPCTL;
706     RegValue &= ~(SIM_CHIPCTL_CLKOUTSEL_MASK | SIM_CHIPCTL_CLKOUTEN_MASK);
707     IP_SIM->CHIPCTL = RegValue;
708 }
Clock_Ip_SetSimClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)709 void Clock_Ip_SetSimClkoutSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
710 {
711     uint32 RegValue;
712     uint32 SelectorValue = Clock_Ip_au16SelectorEntryHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
713 
714     RegValue = IP_SIM->CHIPCTL;
715     RegValue &= ~SIM_CHIPCTL_CLKOUTSEL_MASK;
716     RegValue |= (SelectorValue << SIM_CHIPCTL_CLKOUTSEL_SHIFT);
717     IP_SIM->CHIPCTL = RegValue;
718 }
719 #endif
720 
721 #ifdef CLOCK_IP_PCC_PCS_SELECT
722 /**
723 * @brief            This function will reset writable bit fields of PCC register
724 */
Clock_Ip_ResetPccPcsSelect_TrustedCall(Clock_Ip_SelectorConfigType const * Config)725 void Clock_Ip_ResetPccPcsSelect_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
726 {
727     uint32 PccIndex = Clock_Ip_au8ClockFeatures[Config->Name][CLOCK_IP_SELECTOR_INDEX];
728 
729     /* Disable CGC before set PCS */
730     IP_PCC->PCCn[PccIndex] &= ~(PCC_PCCn_CGC_MASK);
731     IP_PCC->PCCn[PccIndex] &= ~(PCC_PCCn_PCS_MASK);
732 }
Clock_Ip_SetPccPcsSelect_TrustedCall(Clock_Ip_SelectorConfigType const * Config)733 void Clock_Ip_SetPccPcsSelect_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
734 {
735     uint32 RegValue;
736     uint32 PccIndex = Clock_Ip_au8ClockFeatures[Config->Name][CLOCK_IP_SELECTOR_INDEX];
737     uint32 SelectorValue = Clock_Ip_au8SelectorEntryPcsHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
738 
739     RegValue = IP_PCC->PCCn[PccIndex];
740     RegValue &= ~PCC_PCCn_PCS_MASK;
741     RegValue |= PCC_PCCn_PCS(SelectorValue);
742     IP_PCC->PCCn[PccIndex] = RegValue;
743 }
744 #endif
745 
746 #ifdef CLOCK_IP_SIM_TRACE_SEL
Clock_Ip_ResetSimTraceSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)747 void Clock_Ip_ResetSimTraceSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
748 {
749     uint32 RegValue;
750     /* TRACE_CLK selector mapped to Clock_Ip_au16SelectorEntryHardwareValue */
751     uint32 SelectorValue = Clock_Ip_au16SelectorEntryHardwareValue[CORE_CLK];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
752 
753     (void) Config;
754     RegValue = (uint32)IP_SIM->CHIPCTL;
755     RegValue &= (~((uint32)SIM_CHIPCTL_TRACECLK_SEL_MASK));
756     RegValue |= SIM_CHIPCTL_TRACECLK_SEL(SelectorValue);
757     IP_SIM->CHIPCTL = (uint32)RegValue;
758 }
Clock_Ip_SetSimTraceSel_TrustedCall(Clock_Ip_SelectorConfigType const * Config)759 void Clock_Ip_SetSimTraceSel_TrustedCall(Clock_Ip_SelectorConfigType const *Config)
760 {
761     uint32 RegValue;
762     /* TRACE_CLK selector mapped to Clock_Ip_au16SelectorEntryHardwareValue */
763     uint32 SelectorValue = Clock_Ip_au16SelectorEntryHardwareValue[Config->Value];    /* Hw value corresponding to selector entry. Translate input clock source to hardware value. */
764 
765     RegValue = (uint32)IP_SIM->CHIPCTL;
766     RegValue &= (~((uint32)SIM_CHIPCTL_TRACECLK_SEL_MASK));
767     RegValue |= SIM_CHIPCTL_TRACECLK_SEL(SelectorValue);
768     IP_SIM->CHIPCTL = (uint32)RegValue;
769 }
770 #endif
771 
772 /* Clock stop section code */
773 #define MCU_STOP_SEC_CODE
774 
775 #include "Mcu_MemMap.h"
776 
777 /*==================================================================================================
778 *                                        GLOBAL CONSTANTS
779 ==================================================================================================*/
780 
781 /* Clock start constant section data */
782 #define MCU_START_SEC_CONST_UNSPECIFIED
783 
784 #include "Mcu_MemMap.h"
785 
786 const Clock_Ip_SelectorCallbackType Clock_Ip_axSelectorCallbacks[CLOCK_IP_SELECTOR_CALLBACKS_COUNT] =
787 {
788     {
789         Clock_Ip_CallbackSelectorEmpty,            /* Reset */
790         Clock_Ip_CallbackSelectorEmpty,            /* Set */
791     },
792 #ifdef CLOCK_IP_SCG_SCS_RUN_SEL
793     {
794         Clock_Ip_ResetScgRunSel,                 /* Reset */
795         Clock_Ip_SetScgRunSel,                   /* Set */
796     },
797 #endif
798 
799 #ifdef CLOCK_IP_SCG_SCS_VLPR_SEL
800     {
801         Clock_Ip_CallbackSelectorEmpty,          /* Reset */
802         Clock_Ip_SetScgVlprSel,                   /* Set */
803     },
804 #endif
805 
806 #ifdef CLOCK_IP_SCG_SCS_HSRUN_SEL
807     {
808         Clock_Ip_ResetScgHsrunSel,                 /* Reset */
809         Clock_Ip_SetScgHsrunSel,                   /* Set */
810     },
811 #endif
812 
813 #ifdef CLOCK_IP_SIM_RTC_SEL
814     {
815         Clock_Ip_ResetSimRtcSel,                 /* Reset */
816         Clock_Ip_SetSimRtcSel,                   /* Set */
817     },
818 #endif
819 
820 #ifdef CLOCK_IP_SIM_LPO_SEL
821     {
822         Clock_Ip_ResetSimLpoSel,                 /* Reset */
823         Clock_Ip_SetSimLpoSel,                   /* Set */
824     },
825 #endif
826 
827 #ifdef CLOCK_IP_SCG_CLKOUT_SEL
828     {
829         Clock_Ip_ResetScgClkoutSel,             /* Reset */
830         Clock_Ip_SetScgClkoutSel,               /* Set */
831     },
832 #endif
833 
834 #ifdef CLOCK_IP_SIM_FTMOPT_SEL
835     {
836         Clock_Ip_ResetSimFtmoptSel,              /* Reset */
837         Clock_Ip_SetSimFtmoptSel,                /* Set */
838     },
839 #endif
840 
841 #ifdef CLOCK_IP_SIM_CLKOUT_SEL
842     {
843         Clock_Ip_ResetSimClkoutSel,              /* Reset */
844         Clock_Ip_SetSimClkoutSel,                /* Set */
845     },
846 #endif
847 
848 #ifdef CLOCK_IP_PCC_PCS_SELECT
849     {
850         Clock_Ip_ResetPccPcsSelect,              /* Reset */
851         Clock_Ip_SetPccPcsSelect,                /* Set */
852     },
853 #endif
854 
855 #ifdef CLOCK_IP_SIM_TRACE_SEL
856     {
857         Clock_Ip_ResetSimTraceSel,               /* Reset */
858         Clock_Ip_SetSimTraceSel,                 /* Set */
859     },
860 #endif
861 
862 };
863 
864 /* Clock stop constant section data */
865 #define MCU_STOP_SEC_CONST_UNSPECIFIED
866 
867 #include "Mcu_MemMap.h"
868 
869 
870 
871 #ifdef __cplusplus
872 }
873 #endif
874 
875 /** @} */
876