]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K22F/MK22F51212/fsl_sim_hal_K22F51212.c
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_Freescale / TARGET_KPSDK_MCUS / TARGET_K22F / MK22F51212 / fsl_sim_hal_K22F51212.c
1 /*
2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * o Redistributions of source code must retain the above copyright notice, this list
9 * of conditions and the following disclaimer.
10 *
11 * o Redistributions in binary form must reproduce the above copyright notice, this
12 * list of conditions and the following disclaimer in the documentation and/or
13 * other materials provided with the distribution.
14 *
15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include <stdint.h>
32 #include <stdlib.h>
33 #include <stdbool.h>
34 #include "fsl_device_registers.h"
35 #include "fsl_sim_hal_K22F51212.h"
36 #include "fsl_sim_hal.h"
37
38 /*******************************************************************************
39 * Definitions
40 ******************************************************************************/
41
42 /*! @brief CLOCK name config table for K64*/
43 const clock_name_config_t kClockNameConfigTable [] = {
44 {false, kSystemClock, kClockDividerOutdiv1},
45 {false, kSystemClock, kClockDividerOutdiv1},
46 {false, kSystemClock, kClockDividerOutdiv1},
47 {false, kSystemClock, kClockDividerOutdiv2},
48 {false, kSystemClock, kClockDividerOutdiv3},
49 {false, kSystemClock, kClockDividerOutdiv4}
50 };
51
52 /*******************************************************************************
53 * APIs
54 ******************************************************************************/
55
56 /*FUNCTION**********************************************************************
57 *
58 * Function Name : SIM_HAL_EnableDmaClock
59 * Description : Enable the clock for DMA module
60 * This function enables the clock for DMA moudle
61 *
62 *END**************************************************************************/
63 void SIM_HAL_EnableDmaClock(uint32_t baseAddr, uint32_t instance)
64 {
65 BW_SIM_SCGC7_DMA(baseAddr, 1);
66 }
67
68 /*FUNCTION**********************************************************************
69 *
70 * Function Name : SIM_HAL_DisableDmaClock
71 * Description : Disable the clock for DMA module
72 * This function disables the clock for DMA moudle
73 *
74 *END**************************************************************************/
75 void SIM_HAL_DisableDmaClock(uint32_t baseAddr, uint32_t instance)
76 {
77 BW_SIM_SCGC7_DMA(baseAddr, 0);
78 }
79
80 /*FUNCTION**********************************************************************
81 *
82 * Function Name : SIM_HAL_GetDmaGateCmd
83 * Description : Get the the clock gate state for DMA module
84 * This function will get the clock gate state for DMA moudle
85 *
86 *END**************************************************************************/
87 bool SIM_HAL_GetDmaGateCmd(uint32_t baseAddr, uint32_t instance)
88 {
89 return BR_SIM_SCGC7_DMA(baseAddr);
90 }
91
92 /*FUNCTION**********************************************************************
93 *
94 * Function Name : SIM_HAL_EnableDmamuxClock
95 * Description : Enable the clock for DMAMUX module
96 * This function enables the clock for DMAMUX moudle
97 *
98 *END**************************************************************************/
99 void SIM_HAL_EnableDmamuxClock(uint32_t baseAddr, uint32_t instance)
100 {
101 BW_SIM_SCGC6_DMAMUX(baseAddr, 1);
102 }
103
104 /*FUNCTION**********************************************************************
105 *
106 * Function Name : SIM_HAL_DisableDmamuxClock
107 * Description : Disable the clock for DMAMUX module
108 * This function disables the clock for DMAMUX moudle
109 *
110 *END**************************************************************************/
111 void SIM_HAL_DisableDmamuxClock(uint32_t baseAddr, uint32_t instance)
112 {
113 BW_SIM_SCGC6_DMAMUX(baseAddr, 0);
114 }
115
116 /*FUNCTION**********************************************************************
117 *
118 * Function Name : SIM_HAL_GetDmamuxGateCmd
119 * Description : Get the the clock gate state for DMAMUX module
120 * This function will get the clock gate state for DMAMUX moudle
121 *
122 *END**************************************************************************/
123 bool SIM_HAL_GetDmamuxGateCmd(uint32_t baseAddr, uint32_t instance)
124 {
125 return BR_SIM_SCGC6_DMAMUX(baseAddr);
126 }
127
128 /*FUNCTION**********************************************************************
129 *
130 * Function Name : SIM_HAL_EnablePortClock
131 * Description : Enable the clock for PORT module
132 * This function enables the clock for PORT moudle
133 *
134 *END**************************************************************************/
135 void SIM_HAL_EnablePortClock(uint32_t baseAddr, uint32_t instance)
136 {
137 switch (instance)
138 {
139 case 0:
140 BW_SIM_SCGC5_PORTA(baseAddr, 1);
141 break;
142 case 1:
143 BW_SIM_SCGC5_PORTB(baseAddr, 1);
144 break;
145 case 2:
146 BW_SIM_SCGC5_PORTC(baseAddr, 1);
147 break;
148 case 3:
149 BW_SIM_SCGC5_PORTD(baseAddr, 1);
150 break;
151 case 4:
152 BW_SIM_SCGC5_PORTE(baseAddr, 1);
153 break;
154 default:
155 break;
156 }
157 }
158
159 /*FUNCTION**********************************************************************
160 *
161 * Function Name : SIM_HAL_DisablePortClock
162 * Description : Disable the clock for PORT module
163 * This function disables the clock for PORT moudle
164 *
165 *END**************************************************************************/
166 void SIM_HAL_DisablePortClock(uint32_t baseAddr, uint32_t instance)
167 {
168 switch (instance)
169 {
170 case 0:
171 BW_SIM_SCGC5_PORTA(baseAddr, 0);
172 break;
173 case 1:
174 BW_SIM_SCGC5_PORTB(baseAddr, 0);
175 break;
176 case 2:
177 BW_SIM_SCGC5_PORTC(baseAddr, 0);
178 break;
179 case 3:
180 BW_SIM_SCGC5_PORTD(baseAddr, 0);
181 break;
182 case 4:
183 BW_SIM_SCGC5_PORTE(baseAddr, 0);
184 break;
185 default:
186 break;
187 }
188 }
189
190 /*FUNCTION**********************************************************************
191 *
192 * Function Name : SIM_HAL_GetPortGateCmd
193 * Description : Get the the clock gate state for PORT module
194 * This function will get the clock gate state for PORT moudle.
195 *
196 *END**************************************************************************/
197 bool SIM_HAL_GetPortGateCmd(uint32_t baseAddr, uint32_t instance)
198 {
199 bool retValue = false;
200
201 switch (instance)
202 {
203 case 0:
204 retValue = BR_SIM_SCGC5_PORTA(baseAddr);
205 break;
206 case 1:
207 retValue = BR_SIM_SCGC5_PORTB(baseAddr);
208 break;
209 case 2:
210 retValue = BR_SIM_SCGC5_PORTC(baseAddr);
211 break;
212 case 3:
213 retValue = BR_SIM_SCGC5_PORTD(baseAddr);
214 break;
215 case 4:
216 retValue = BR_SIM_SCGC5_PORTE(baseAddr);
217 break;
218 default:
219 retValue = false;
220 break;
221 }
222
223 return retValue;
224 }
225
226 /*FUNCTION**********************************************************************
227 *
228 * Function Name : SIM_HAL_EnableEwmClock
229 * Description : Enable the clock for EWM module
230 * This function enables the clock for EWM moudle.
231 *
232 *END**************************************************************************/
233 void SIM_HAL_EnableEwmClock(uint32_t baseAddr, uint32_t instance)
234 {
235 BW_SIM_SCGC4_EWM(baseAddr, 1);
236 }
237
238 /*FUNCTION**********************************************************************
239 *
240 * Function Name : SIM_HAL_DisableEwmClock
241 * Description : Disable the clock for EWM modul
242 * This function disables the clock for EWM moudle.
243 *
244 *END**************************************************************************/
245 void SIM_HAL_DisableEwmClock(uint32_t baseAddr, uint32_t instance)
246 {
247 BW_SIM_SCGC4_EWM(baseAddr, 0);
248 }
249
250 /*FUNCTION**********************************************************************
251 *
252 * Function Name : SIM_HAL_GetEwmGateCmd
253 * Description : Get the the clock gate state for EWM module
254 * This function will get the clock gate state for EWM moudle.
255 *
256 *END**************************************************************************/
257 bool SIM_HAL_GetEwmGateCmd(uint32_t baseAddr, uint32_t instance)
258 {
259 return BR_SIM_SCGC4_EWM(baseAddr);
260 }
261
262 /*FUNCTION**********************************************************************
263 *
264 * Function Name : SIM_HAL_EnableFlexbusClock
265 * Description : Enable the clock for FLEXBUS module
266 * This function enables the clock for FLEXBUS moudle.
267 *
268 *END**************************************************************************/
269 void SIM_HAL_EnableFlexbusClock(uint32_t baseAddr, uint32_t instance)
270 {
271 BW_SIM_SCGC7_FLEXBUS(baseAddr, 1);
272 }
273
274 /*FUNCTION**********************************************************************
275 *
276 * Function Name : SIM_HAL_DisableFlexbusClock
277 * Description : Disable the clock for FLEXBUS module
278 * This function disables the clock for FLEXBUS moudle.
279 *
280 *END**************************************************************************/
281 void SIM_HAL_DisableFlexbusClock(uint32_t baseAddr, uint32_t instance)
282 {
283 BW_SIM_SCGC7_FLEXBUS(baseAddr, 0);
284 }
285
286 /*FUNCTION**********************************************************************
287 *
288 * Function Name : SIM_HAL_GetFlexbusGateCmd
289 * Description : Get the the clock gate state for FLEXBUS module
290 * This function will get the clock gate state for FLEXBUS moudle.
291 *
292 *END**************************************************************************/
293 bool SIM_HAL_GetFlexbusGateCmd(uint32_t baseAddr, uint32_t instance)
294 {
295 return BR_SIM_SCGC7_FLEXBUS(baseAddr);
296 }
297
298 /*FUNCTION**********************************************************************
299 *
300 * Function Name : SIM_HAL_EnableFtfClock
301 * Description : Enable the clock for FTF module
302 * This function enables the clock for FTF moudle.
303 *
304 *END**************************************************************************/
305 void SIM_HAL_EnableFtfClock(uint32_t baseAddr, uint32_t instance)
306 {
307 BW_SIM_SCGC6_FTF(baseAddr, 1);
308 }
309
310 /*FUNCTION**********************************************************************
311 *
312 * Function Name : SIM_HAL_DisableFtfClock
313 * Description : Disable the clock for FTF module
314 * This function disables the clock for FTF moudle.
315 *
316 *END**************************************************************************/
317 void SIM_HAL_DisableFtfClock(uint32_t baseAddr, uint32_t instance)
318 {
319 BW_SIM_SCGC6_FTF(baseAddr, 0);
320 }
321
322 /*FUNCTION**********************************************************************
323 *
324 * Function Name : SIM_HAL_GetFtfGateCmd
325 * Description : Get the the clock gate state for FTF module
326 * This function will get the clock gate state for FTF moudle.
327 *
328 *END**************************************************************************/
329 bool SIM_HAL_GetFtfGateCmd(uint32_t baseAddr, uint32_t instance)
330 {
331 return BR_SIM_SCGC6_FTF(baseAddr);
332 }
333
334 /*FUNCTION**********************************************************************
335 *
336 * Function Name : SIM_HAL_EnableCrcClock
337 * Description : Enable the clock for CRC module
338 * This function enables the clock for CRC moudle.
339 *
340 *END**************************************************************************/
341 void SIM_HAL_EnableCrcClock(uint32_t baseAddr, uint32_t instance)
342 {
343 BW_SIM_SCGC6_CRC(baseAddr, 1);
344 }
345
346 /*FUNCTION**********************************************************************
347 *
348 * Function Name : SIM_HAL_DisableCrcClock
349 * Description : Disable the clock for CRC module
350 * This function disables the clock for CRC moudle.
351 *
352 *END**************************************************************************/
353 void SIM_HAL_DisableCrcClock(uint32_t baseAddr, uint32_t instance)
354 {
355 BW_SIM_SCGC6_CRC(baseAddr, 0);
356 }
357
358 /*FUNCTION**********************************************************************
359 *
360 * Function Name : SIM_HAL_GetCrcGateCmd
361 * Description : Get the the clock gate state for CRC module
362 * This function will get the clock gate state for CRC moudle.
363 *
364 *END**************************************************************************/
365 bool SIM_HAL_GetCrcGateCmd(uint32_t baseAddr, uint32_t instance)
366 {
367 return BR_SIM_SCGC6_CRC(baseAddr);
368 }
369
370 /*FUNCTION**********************************************************************
371 *
372 * Function Name : SIM_HAL_EnableRngaClock
373 * Description : Enable the clock for RNGA module
374 * This function enables the clock for RNGA moudle.
375 *
376 *END**************************************************************************/
377 void SIM_HAL_EnableRngaClock(uint32_t baseAddr, uint32_t instance)
378 {
379 BW_SIM_SCGC6_RNGA(baseAddr, 1);
380 }
381
382 /*FUNCTION**********************************************************************
383 *
384 * Function Name : SIM_HAL_DisableRngaClock
385 * Description : Disable the clock for RNGA module
386 * This function disables the clock for RNGA moudle.
387 *
388 *END**************************************************************************/
389 void SIM_HAL_DisableRngaClock(uint32_t baseAddr, uint32_t instance)
390 {
391 BW_SIM_SCGC6_RNGA(baseAddr, 0);
392 }
393
394 /*FUNCTION**********************************************************************
395 *
396 * Function Name : SIM_HAL_GetRngaGateCmd
397 * Description : Get the the clock gate state for RNGA module
398 * This function will get the clock gate state for RNGA moudle.
399 *
400 *END**************************************************************************/
401 bool SIM_HAL_GetRngaGateCmd(uint32_t baseAddr, uint32_t instance)
402 {
403 return BR_SIM_SCGC6_RNGA(baseAddr);
404 }
405
406 /*FUNCTION**********************************************************************
407 *
408 * Function Name : SIM_HAL_EnableAdcClock
409 * Description : Enable the clock for ADC module
410 * This function enables the clock for ADC moudle
411 *
412 *END**************************************************************************/
413 void SIM_HAL_EnableAdcClock(uint32_t baseAddr, uint32_t instance)
414 {
415 switch (instance)
416 {
417 case 0:
418 BW_SIM_SCGC6_ADC0(baseAddr, 1);
419 break;
420 case 1:
421 BW_SIM_SCGC6_ADC1(baseAddr, 1);
422 break;
423 default:
424 break;
425 }
426 }
427
428 /*FUNCTION**********************************************************************
429 *
430 * Function Name : SIM_HAL_DisableAdcClock
431 * Description : Disable the clock for ADC module
432 * This function disables the clock for ADC moudle
433 *
434 *END**************************************************************************/
435 void SIM_HAL_DisableAdcClock(uint32_t baseAddr, uint32_t instance)
436 {
437 switch (instance)
438 {
439 case 0:
440 BW_SIM_SCGC6_ADC0(baseAddr, 0);
441 break;
442 case 1:
443 BW_SIM_SCGC6_ADC1(baseAddr, 0);
444 break;
445 default:
446 break;
447 }
448 }
449
450 /*FUNCTION**********************************************************************
451 *
452 * Function Name : SIM_HAL_GetAdcGateCmd
453 * Description : Get the the clock gate state for ADC module
454 * This function will get the clock gate state for ADC moudle.
455 *
456 *END**************************************************************************/
457 bool SIM_HAL_GetAdcGateCmd(uint32_t baseAddr, uint32_t instance)
458 {
459 bool retValue = false;
460
461 switch (instance)
462 {
463 case 0:
464 retValue = BR_SIM_SCGC6_ADC0(baseAddr);
465 break;
466 case 1:
467 retValue = BR_SIM_SCGC6_ADC1(baseAddr);
468 break;
469 default:
470 retValue = false;
471 break;
472 }
473
474 return retValue;
475 }
476
477 /*FUNCTION**********************************************************************
478 *
479 * Function Name : SIM_HAL_EnableCmpClock
480 * Description : Enable the clock for CMP module
481 * This function enables the clock for CMP moudle
482 *
483 *END**************************************************************************/
484 void SIM_HAL_EnableCmpClock(uint32_t baseAddr, uint32_t instance)
485 {
486 BW_SIM_SCGC4_CMP(baseAddr, 1);
487 }
488
489 /*FUNCTION**********************************************************************
490 *
491 * Function Name : SIM_HAL_DisableCmpClock
492 * Description : Disable the clock for CMP module
493 * This function disables the clock for CMP moudle
494 *
495 *END**************************************************************************/
496 void SIM_HAL_DisableCmpClock(uint32_t baseAddr, uint32_t instance)
497 {
498 BW_SIM_SCGC4_CMP(baseAddr, 0);
499 }
500
501 /*FUNCTION**********************************************************************
502 *
503 * Function Name : SIM_HAL_GetCmpGateCmd
504 * Description : Get the the clock gate state for CMP module
505 * This function will get the clock gate state for CMP moudle.
506 *
507 *END**************************************************************************/
508 bool SIM_HAL_GetCmpGateCmd(uint32_t baseAddr, uint32_t instance)
509 {
510 return BR_SIM_SCGC4_CMP(baseAddr);
511 }
512
513 /*FUNCTION**********************************************************************
514 *
515 * Function Name : SIM_HAL_EnableDacClock
516 * Description : Enable the clock for DAC module
517 * This function enables the clock for DAC moudle
518 *
519 *END**************************************************************************/
520 void SIM_HAL_EnableDacClock(uint32_t baseAddr, uint32_t instance)
521 {
522 switch (instance)
523 {
524 case 0:
525 BW_SIM_SCGC6_DAC0(baseAddr, 1);
526 break;
527 case 1:
528 BW_SIM_SCGC6_DAC1(baseAddr, 1);
529 break;
530 default:
531 break;
532 }
533 }
534
535 /*FUNCTION**********************************************************************
536 *
537 * Function Name : SIM_HAL_DisableDacClock
538 * Description : Disable the clock for DAC module
539 * This function disables the clock for DAC moudle
540 *
541 *END**************************************************************************/
542 void SIM_HAL_DisableDacClock(uint32_t baseAddr, uint32_t instance)
543 {
544 switch (instance)
545 {
546 case 0:
547 BW_SIM_SCGC6_DAC0(baseAddr, 0);
548 break;
549 case 1:
550 BW_SIM_SCGC6_DAC1(baseAddr, 0);
551 break;
552 default:
553 break;
554 }
555 }
556
557 /*FUNCTION**********************************************************************
558 *
559 * Function Name : SIM_HAL_GetDacGateCmd
560 * Description : Get the the clock gate state for DAC module
561 * This function will get the clock gate state for DAC moudle.
562 *
563 *END**************************************************************************/
564 bool SIM_HAL_GetDacGateCmd(uint32_t baseAddr, uint32_t instance)
565 {
566 bool retValue = false;
567
568 switch (instance)
569 {
570 case 0:
571 retValue = BR_SIM_SCGC6_DAC0(baseAddr);
572 break;
573 case 1:
574 retValue = BR_SIM_SCGC6_DAC1(baseAddr);
575 break;
576 default:
577 retValue = false;
578 break;
579 }
580
581 return retValue;
582 }
583
584 /*FUNCTION**********************************************************************
585 *
586 * Function Name : SIM_HAL_EnableVrefClock
587 * Description : Enable the clock for VREF module
588 * This function enables the clock for VREF moudle
589 *
590 *END**************************************************************************/
591 void SIM_HAL_EnableVrefClock(uint32_t baseAddr, uint32_t instance)
592 {
593 BW_SIM_SCGC4_VREF(baseAddr, 1);
594 }
595
596 /*FUNCTION**********************************************************************
597 *
598 * Function Name : SIM_HAL_DisableVrefClock
599 * Description : Disable the clock for VREF module
600 * This function disables the clock for VREF moudle
601 *
602 *END**************************************************************************/
603 void SIM_HAL_DisableVrefClock(uint32_t baseAddr, uint32_t instance)
604 {
605 BW_SIM_SCGC4_VREF(baseAddr, 0);
606 }
607
608 /*FUNCTION**********************************************************************
609 *
610 * Function Name : SIM_HAL_GetVrefGateCmd
611 * Description : Get the the clock gate state for VREF module
612 * This function will get the clock gate state for VREF moudle.
613 *
614 *END**************************************************************************/
615 bool SIM_HAL_GetVrefGateCmd(uint32_t baseAddr, uint32_t instance)
616 {
617 return BR_SIM_SCGC4_VREF(baseAddr);
618 }
619
620 /*FUNCTION**********************************************************************
621 *
622 * Function Name : SIM_HAL_EnableSaiClock
623 * Description : Enable the clock for SAI module
624 * This function enables the clock for SAI moudle
625 *
626 *END**************************************************************************/
627 void SIM_HAL_EnableSaiClock(uint32_t baseAddr, uint32_t instance)
628 {
629 BW_SIM_SCGC6_I2S(baseAddr, 1);
630 }
631
632 /*FUNCTION**********************************************************************
633 *
634 * Function Name : SIM_HAL_DisableSaiClock
635 * Description : Disable the clock for SAI module
636 * This function disables the clock for SAI moudle
637 *
638 *END**************************************************************************/
639 void SIM_HAL_DisableSaiClock(uint32_t baseAddr, uint32_t instance)
640 {
641 BW_SIM_SCGC6_I2S(baseAddr, 0);
642 }
643
644 /*FUNCTION**********************************************************************
645 *
646 * Function Name : SIM_HAL_GetSaiGateCmd
647 * Description : Get the the clock gate state for SAI module
648 * This function will get the clock gate state for SAI moudle.
649 *
650 *END**************************************************************************/
651 bool SIM_HAL_GetSaiGateCmd(uint32_t baseAddr, uint32_t instance)
652 {
653 return BR_SIM_SCGC6_I2S(baseAddr);
654 }
655
656 /*FUNCTION**********************************************************************
657 *
658 * Function Name : SIM_HAL_EnablePdbClock
659 * Description : Enable the clock for PDB module
660 * This function enables the clock for PDB moudle
661 *
662 *END**************************************************************************/
663 void SIM_HAL_EnablePdbClock(uint32_t baseAddr, uint32_t instance)
664 {
665 BW_SIM_SCGC6_PDB(baseAddr, 1);
666 }
667
668 /*FUNCTION**********************************************************************
669 *
670 * Function Name : SIM_HAL_DisablePdbClock
671 * Description : Disable the clock for PDB module
672 * This function disables the clock for PDB moudle
673 *
674 *END**************************************************************************/
675 void SIM_HAL_DisablePdbClock(uint32_t baseAddr, uint32_t instance)
676 {
677 BW_SIM_SCGC6_PDB(baseAddr, 0);
678 }
679
680 /*FUNCTION**********************************************************************
681 *
682 * Function Name : SIM_HAL_GetPdbGateCmd
683 * Description : Get the the clock gate state for PDB module
684 * This function will get the clock gate state for PDB moudle.
685 *
686 *END**************************************************************************/
687 bool SIM_HAL_GetPdbGateCmd(uint32_t baseAddr, uint32_t instance)
688 {
689 return BR_SIM_SCGC6_PDB(baseAddr);
690 }
691
692 /*FUNCTION**********************************************************************
693 *
694 * Function Name : SIM_HAL_EnableFtmClock
695 * Description : Enable the clock for FTM module
696 * This function enables the clock for FTM moudle
697 *
698 *END**************************************************************************/
699 void SIM_HAL_EnableFtmClock(uint32_t baseAddr, uint32_t instance)
700 {
701 switch (instance)
702 {
703 case 0:
704 BW_SIM_SCGC6_FTM0(baseAddr, 1);
705 break;
706 case 1:
707 BW_SIM_SCGC6_FTM1(baseAddr, 1);
708 break;
709 case 2:
710 BW_SIM_SCGC6_FTM2(baseAddr, 1);
711 break;
712 case 3:
713 BW_SIM_SCGC6_FTM3(baseAddr, 1);
714 break;
715 default:
716 break;
717 }
718 }
719
720 /*FUNCTION**********************************************************************
721 *
722 * Function Name : SIM_HAL_DisableFtmClock
723 * Description : Disable the clock for FTM module
724 * This function disables the clock for FTM moudle
725 *
726 *END**************************************************************************/
727 void SIM_HAL_DisableFtmClock(uint32_t baseAddr, uint32_t instance)
728 {
729 switch (instance)
730 {
731 case 0:
732 BW_SIM_SCGC6_FTM0(baseAddr, 0);
733 break;
734 case 1:
735 BW_SIM_SCGC6_FTM1(baseAddr, 0);
736 break;
737 case 2:
738 BW_SIM_SCGC6_FTM2(baseAddr, 0);
739 break;
740 case 3:
741 BW_SIM_SCGC6_FTM3(baseAddr, 0);
742 break;
743 default:
744 break;
745 }
746 }
747
748 /*FUNCTION**********************************************************************
749 *
750 * Function Name : SIM_HAL_GetFtmGateCmd
751 * Description : Get the the clock gate state for FTM module
752 * This function will get the clock gate state for FTM moudle.
753 *
754 *END**************************************************************************/
755 bool SIM_HAL_GetFtmGateCmd(uint32_t baseAddr, uint32_t instance)
756 {
757 bool retValue = false;
758
759 switch (instance)
760 {
761 case 0:
762 retValue = BR_SIM_SCGC6_FTM0(baseAddr);
763 break;
764 case 1:
765 retValue = BR_SIM_SCGC6_FTM1(baseAddr);
766 break;
767 case 2:
768 retValue = BR_SIM_SCGC6_FTM2(baseAddr);
769 break;
770 case 3:
771 retValue = BR_SIM_SCGC6_FTM3(baseAddr);
772 break;
773 default:
774 retValue = false;
775 break;
776 }
777
778 return retValue;
779 }
780
781 /*FUNCTION**********************************************************************
782 *
783 * Function Name : SIM_HAL_EnablePitClock
784 * Description : Enable the clock for PIT module
785 * This function enables the clock for PIT moudle
786 *
787 *END**************************************************************************/
788 void SIM_HAL_EnablePitClock(uint32_t baseAddr, uint32_t instance)
789 {
790 BW_SIM_SCGC6_PIT(baseAddr, 1);
791 }
792
793 /*FUNCTION**********************************************************************
794 *
795 * Function Name : SIM_HAL_DisablePitClock
796 * Description : Disable the clock for PIT module
797 * This function disables the clock for PIT moudle
798 *
799 *END**************************************************************************/
800 void SIM_HAL_DisablePitClock(uint32_t baseAddr, uint32_t instance)
801 {
802 BW_SIM_SCGC6_PIT(baseAddr, 0);
803 }
804
805 /*FUNCTION**********************************************************************
806 *
807 * Function Name : SIM_HAL_GetPitGateCmd
808 * Description : Get the the clock gate state for PIT module
809 * This function will get the clock gate state for PIT moudle.
810 *
811 *END**************************************************************************/
812 bool SIM_HAL_GetPitGateCmd(uint32_t baseAddr, uint32_t instance)
813 {
814 return BR_SIM_SCGC6_PIT(baseAddr);
815 }
816
817 /*FUNCTION**********************************************************************
818 *
819 * Function Name : SIM_HAL_EnableLptimerClock
820 * Description : Enable the clock for LPTIMER module
821 * This function enables the clock for LPTIMER moudle
822 *
823 *END**************************************************************************/
824 void SIM_HAL_EnableLptimerClock(uint32_t baseAddr, uint32_t instance)
825 {
826 BW_SIM_SCGC5_LPTMR(baseAddr, 1);
827 }
828
829 /*FUNCTION**********************************************************************
830 *
831 * Function Name : SIM_HAL_DisableLptimerClock
832 * Description : Disable the clock for LPTIMER module
833 * This function disables the clock for LPTIMER moudle
834 *
835 *END**************************************************************************/
836 void SIM_HAL_DisableLptimerClock(uint32_t baseAddr, uint32_t instance)
837 {
838 BW_SIM_SCGC5_LPTMR(baseAddr, 0);
839 }
840
841 /*FUNCTION**********************************************************************
842 *
843 * Function Name : SIM_HAL_GetLptimerGateCmd
844 * Description : Get the the clock gate state for LPTIMER module
845 * This function will get the clock gate state for LPTIMER moudle.
846 *
847 *END**************************************************************************/
848 bool SIM_HAL_GetLptimerGateCmd(uint32_t baseAddr, uint32_t instance)
849 {
850 return BR_SIM_SCGC5_LPTMR(baseAddr);
851 }
852
853 /*FUNCTION**********************************************************************
854 *
855 * Function Name : SIM_HAL_EnableRtcClock
856 * Description : Enable the clock for RTC module
857 * This function enables the clock for RTC moudle
858 *
859 *END**************************************************************************/
860 void SIM_HAL_EnableRtcClock(uint32_t baseAddr, uint32_t instance)
861 {
862 BW_SIM_SCGC6_RTC(baseAddr, 1);
863 }
864
865 /*FUNCTION**********************************************************************
866 *
867 * Function Name : SIM_HAL_DisableRtcClock
868 * Description : Disable the clock for RTC module
869 * This function disables the clock for RTC moudle
870 *
871 *END**************************************************************************/
872 void SIM_HAL_DisableRtcClock(uint32_t baseAddr, uint32_t instance)
873 {
874 BW_SIM_SCGC6_RTC(baseAddr, 0);
875 }
876
877 /*FUNCTION**********************************************************************
878 *
879 * Function Name : SIM_HAL_GetRtcGateCmd
880 * Description : Get the the clock gate state for RTC module
881 * This function will get the clock gate state for RTC moudle.
882 *
883 *END**************************************************************************/
884 bool SIM_HAL_GetRtcGateCmd(uint32_t baseAddr, uint32_t instance)
885 {
886 return BR_SIM_SCGC6_RTC(baseAddr);
887 }
888
889 /*FUNCTION**********************************************************************
890 *
891 * Function Name : SIM_HAL_EnableUsbClock
892 * Description : Enable the clock for USBFS module
893 * This function enables the clock for USBFS moudle
894 *
895 *END**************************************************************************/
896 void SIM_HAL_EnableUsbClock(uint32_t baseAddr, uint32_t instance)
897 {
898 BW_SIM_SCGC4_USBOTG(baseAddr, 1);
899 }
900
901 /*FUNCTION**********************************************************************
902 *
903 * Function Name : SIM_HAL_DisableUsbClock
904 * Description : Disable the clock for USBFS module
905 * This function disables the clock for USBFS moudle
906 *
907 *END**************************************************************************/
908 void SIM_HAL_DisableUsbClock(uint32_t baseAddr, uint32_t instance)
909 {
910 BW_SIM_SCGC4_USBOTG(baseAddr, 0);
911 }
912
913 /*FUNCTION**********************************************************************
914 *
915 * Function Name : SIM_HAL_GetUsbGateCmd
916 * Description : Get the the clock gate state for USB module
917 * This function will get the clock gate state for USB moudle.
918 *
919 *END**************************************************************************/
920 bool SIM_HAL_GetUsbGateCmd(uint32_t baseAddr, uint32_t instance)
921 {
922 return BR_SIM_SCGC4_USBOTG(baseAddr);
923 }
924
925 /*FUNCTION**********************************************************************
926 *
927 * Function Name : SIM_HAL_EnableSpiClock
928 * Description : Enable the clock for SPI module
929 * This function enables the clock for SPI moudle
930 *
931 *END**************************************************************************/
932 void SIM_HAL_EnableSpiClock(uint32_t baseAddr, uint32_t instance)
933 {
934 switch (instance)
935 {
936 case 0:
937 BW_SIM_SCGC6_SPI0(baseAddr, 1);
938 break;
939 case 1:
940 BW_SIM_SCGC6_SPI1(baseAddr, 1);
941 break;
942 default:
943 break;
944 }
945 }
946
947 /*FUNCTION**********************************************************************
948 *
949 * Function Name : SIM_HAL_DisableSpiClock
950 * Description : Disable the clock for SPI module
951 * This function disables the clock for SPI moudle
952 *
953 *END**************************************************************************/
954 void SIM_HAL_DisableSpiClock(uint32_t baseAddr, uint32_t instance)
955 {
956 switch (instance)
957 {
958 case 0:
959 BW_SIM_SCGC6_SPI0(baseAddr, 0);
960 break;
961 case 1:
962 BW_SIM_SCGC6_SPI1(baseAddr, 0);
963 break;
964 default:
965 break;
966 }
967 }
968
969 /*FUNCTION**********************************************************************
970 *
971 * Function Name : SIM_HAL_GetSpiGateCmd
972 * Description : Get the the clock gate state for SPI module
973 * This function will get the clock gate state for SPI moudle.
974 *
975 *END**************************************************************************/
976 bool SIM_HAL_GetSpiGateCmd(uint32_t baseAddr, uint32_t instance)
977 {
978 bool retValue = false;
979
980 switch (instance)
981 {
982 case 0:
983 retValue = BR_SIM_SCGC6_SPI0(baseAddr);
984 break;
985 case 1:
986 retValue = BR_SIM_SCGC6_SPI1(baseAddr);
987 break;
988 default:
989 retValue = false;
990 break;
991 }
992
993 return retValue;
994 }
995
996 /*FUNCTION**********************************************************************
997 *
998 * Function Name : SIM_HAL_EnableI2cClock
999 * Description : Enable the clock for I2C module
1000 * This function enables the clock for I2C moudle
1001 *
1002 *END**************************************************************************/
1003 void SIM_HAL_EnableI2cClock(uint32_t baseAddr, uint32_t instance)
1004 {
1005 switch (instance)
1006 {
1007 case 0:
1008 BW_SIM_SCGC4_I2C0(baseAddr, 1);
1009 break;
1010 case 1:
1011 BW_SIM_SCGC4_I2C1(baseAddr, 1);
1012 break;
1013 default:
1014 break;
1015 }
1016 }
1017
1018 /*FUNCTION**********************************************************************
1019 *
1020 * Function Name : SIM_HAL_DisableI2cClock
1021 * Description : Disable the clock for I2C module
1022 * This function disables the clock for I2C moudle
1023 *
1024 *END**************************************************************************/
1025 void SIM_HAL_DisableI2cClock(uint32_t baseAddr, uint32_t instance)
1026 {
1027 switch (instance)
1028 {
1029 case 0:
1030 BW_SIM_SCGC4_I2C0(baseAddr, 0);
1031 break;
1032 case 1:
1033 BW_SIM_SCGC4_I2C1(baseAddr, 0);
1034 break;
1035 default:
1036 break;
1037 }
1038 }
1039
1040 /*FUNCTION**********************************************************************
1041 *
1042 * Function Name : SIM_HAL_GetI2cGateCmd
1043 * Description : Get the the clock gate state for I2C module
1044 * This function will get the clock gate state for I2C moudle.
1045 *
1046 *END**************************************************************************/
1047 bool SIM_HAL_GetI2cGateCmd(uint32_t baseAddr, uint32_t instance)
1048 {
1049 bool retValue = false;
1050
1051 switch (instance)
1052 {
1053 case 0:
1054 retValue = BR_SIM_SCGC4_I2C0(baseAddr);
1055 break;
1056 case 1:
1057 retValue = BR_SIM_SCGC4_I2C1(baseAddr);
1058 break;
1059 default:
1060 retValue = false;
1061 break;
1062 }
1063
1064 return retValue;
1065 }
1066
1067 /*FUNCTION**********************************************************************
1068 *
1069 * Function Name : SIM_HAL_EnableUartClock
1070 * Description : Enable the clock for UART module
1071 * This function enables the clock for UART moudle
1072 *
1073 *END**************************************************************************/
1074 void SIM_HAL_EnableUartClock(uint32_t baseAddr, uint32_t instance)
1075 {
1076 switch (instance)
1077 {
1078 case 0:
1079 BW_SIM_SCGC4_UART0(baseAddr, 1);
1080 break;
1081 case 1:
1082 BW_SIM_SCGC4_UART1(baseAddr, 1);
1083 break;
1084 case 2:
1085 BW_SIM_SCGC4_UART2(baseAddr, 1);
1086 break;
1087 default:
1088 break;
1089 }
1090 }
1091
1092 /*FUNCTION**********************************************************************
1093 *
1094 * Function Name : SIM_HAL_DisableUartClock
1095 * Description : Disable the clock for UART module
1096 * This function disables the clock for UART moudle
1097 *
1098 *END**************************************************************************/
1099 void SIM_HAL_DisableUartClock(uint32_t baseAddr, uint32_t instance)
1100 {
1101 switch (instance)
1102 {
1103 case 0:
1104 BW_SIM_SCGC4_UART0(baseAddr, 0);
1105 break;
1106 case 1:
1107 BW_SIM_SCGC4_UART1(baseAddr, 0);
1108 break;
1109 case 2:
1110 BW_SIM_SCGC4_UART2(baseAddr, 0);
1111 break;
1112 default:
1113 break;
1114 }
1115 }
1116
1117 /*FUNCTION**********************************************************************
1118 *
1119 * Function Name : SIM_HAL_GetUartGateCmd
1120 * Description : Get the the clock gate state for UART module
1121 * This function will get the clock gate state for UART moudle.
1122 *
1123 *END**************************************************************************/
1124 bool SIM_HAL_GetUartGateCmd(uint32_t baseAddr, uint32_t instance)
1125 {
1126 bool retValue = false;
1127
1128 switch (instance)
1129 {
1130 case 0:
1131 retValue = BR_SIM_SCGC4_UART0(baseAddr);
1132 break;
1133 case 1:
1134 retValue = BR_SIM_SCGC4_UART1(baseAddr);
1135 break;
1136 case 2:
1137 retValue = BR_SIM_SCGC4_UART2(baseAddr);
1138 break;
1139 default:
1140 retValue = false;
1141 break;
1142 }
1143
1144 return retValue;
1145 }
1146
1147
1148 /*FUNCTION**********************************************************************
1149 *
1150 * Function Name : SIM_HAL_EnableLpuartClock
1151 * Description : Enable the clock for LPUART module
1152 * This function enables the clock for LPUART moudle
1153 *
1154 *END**************************************************************************/
1155 void SIM_HAL_EnableLpuartClock(uint32_t baseAddr, uint32_t instance)
1156 {
1157 BW_SIM_SCGC6_LPUART0(baseAddr, 1);
1158 }
1159
1160 /*FUNCTION**********************************************************************
1161 *
1162 * Function Name : SIM_HAL_DisableLpuartClock
1163 * Description : Disable the clock for LPUART module
1164 * This function disables the clock for LPUART moudle
1165 *
1166 *END**************************************************************************/
1167 void SIM_HAL_DisableLpuartClock(uint32_t baseAddr, uint32_t instance)
1168 {
1169 BW_SIM_SCGC6_LPUART0(baseAddr, 0);
1170 }
1171
1172 /*FUNCTION**********************************************************************
1173 *
1174 * Function Name : SIM_HAL_GetLpuartGateCmd
1175 * Description : Get the the clock gate state for LPUART module
1176 * This function will get the clock gate state for LPUART moudle.
1177 *
1178 *END**************************************************************************/
1179 bool SIM_HAL_GetLpuartGateCmd(uint32_t baseAddr, uint32_t instance)
1180 {
1181 return BR_SIM_SCGC6_LPUART0(baseAddr);
1182 }
1183
1184 /*******************************************************************************
1185 * EOF
1186 ******************************************************************************/
1187
Imprint / Impressum